GithubHelp home page GithubHelp logo

Comments (5)

mekhami avatar mekhami commented on August 27, 2024

To clarify, it seems to happen when using Joined Table Inheritance

from sqlakeyset.

chenghlee avatar chenghlee commented on August 27, 2024

To clarify, this is the inheritance pattern that triggers the error:

from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class Parent(Base):
    id_ = Column(Integer, primary_key=True)
    cls = Column(Integer, nullable=False, default=0)
    name = Column(String)

    __tablename__ = 'parent'
    __mapper_args__ = {
        'polymorphic_on': cls,
        'polymorphic_identity': 0
    }


class ChildA(Parent):
    child_a_id = Column(Integer, ForeignKey('parent.id_'), primary_key=True)

    __tablename__ = 'child_a'
    __mapper_args__ = {'polymorphic_identity': 1}


class ChildB(Parent):
    child_b_id = Column(Integer, ForeignKey('parent.id_'), primary_key=True)

    __tablename__ = 'child_b'
    __mapper_args__ = {'polymorphic_identity': 2}

The problem seems to come from paging.py, line 74

if entity.__tablename__ == ocol.table_name:

For the joined table inheritance pattern, entity.__tablename__ is not equal to ocol.table_name if ocol comes from the parent table. If you replace that if with something like:

if hasattr(thing, ocol.name):

this bug disappears. But strong warning, I'm not 100% where using hasattr would break any or everything else in the package.

from sqlakeyset.

djrobstep avatar djrobstep commented on August 27, 2024

Hi, thank you to both of you for reporting this issue!

@chenghlee your suggested change and rationale seems reasonable and I'm happy to make this change (provided the existing tests still pass of course). Do either of you feel like putting together a pull request for this with a simple test case?

Or else I'll fix it up when I get around to it, however that may take a while as I am rather busy at the moment.

from sqlakeyset.

chenghlee avatar chenghlee commented on August 27, 2024

@djrobstep: I should have some time over the next few days to put together a pull request for this.

from sqlakeyset.

djrobstep avatar djrobstep commented on August 27, 2024

@chenghlee Super stuff! If you have any questions about the code or whatever just ask.

from sqlakeyset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.