Comments (5)
To clarify, it seems to happen when using Joined Table Inheritance
from sqlakeyset.
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.
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.
@djrobstep: I should have some time over the next few days to put together a pull request for this.
from sqlakeyset.
@chenghlee Super stuff! If you have any questions about the code or whatever just ask.
from sqlakeyset.
Related Issues (20)
- SQLite compatibility HOT 3
- Tuple/ROW comparison not supported in Oracle and SQL Server HOT 4
- Support SQLAlchemy 2.0-style ORM queries HOT 11
- Custom binding logic issue HOT 2
- Support multiple engines in one Session
- ORM Query is called 3 times.
- Get the total number of pages and / or records returned by query HOT 2
- First queries are unbounded HOT 1
- When paging backwards, page.paging.items() seems to misalign bookmarks and values HOT 6
- Add type hints HOT 2
- Sorting by literal_column produces invalid SQL and fails HOT 2
- ImportError: cannot import name 'LegacyRow' from 'sqlalchemy.engine.row' HOT 2
- Question: Converting Page to Pydantic Model HOT 2
- FeatureRequest: get_pages/select_pages HOT 1
- asyncpg uuid support HOT 1
- asyncio paging returns tuples of length 1 HOT 1
- Breaks on sqlalchemy & flask-sqlalchemy on a simple model HOT 3
- SQLAlchemy 2 wrong type for column desc HOT 4
- Breaks when using sqlalchemy session HOT 2
- `row._mapping` is broken after pagination HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlakeyset.