-
-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Declarative backref rels not filtering by polymorphic identity #492
Comments
likely because tablename is set to non-None in all cases now: https://github.com/mitsuhiko/flask-sqlalchemy/blob/master/flask_sqlalchemy/__init__.py#L641 that should be None to indicate single inheritance. |
@zzzeek it should be unset on the "base" classes, but set on the "child" classes? to the same thing? |
whichever class should have its own table gets tablename, whichever subclass that's single inh either should not have tablename at all (declarative looks in cls.dict to check that the attribute is local to a certain class) or it should return None - declarative then sets that mapper as single=True. Basically the way db.Model here wants to do tablename, if it has that feature then you need to set tablename = None on your model. |
I'm working on fixing the tablename logic, I'll keep this example in mind. |
Btw, the title of the bug is incorrect: it doesn't really involve relationships at all. It is that queries that specify a subclass do not emit a where clause when using polymorphic identity in single table, so effectively, the type is ignored. Here's an example:
Based on the hint from @zzzeek , if you uncomment the This seems to be a pretty serious bug. Hope it gets fixed soon. |
More info here:
https://bitbucket.org/zzzeek/sqlalchemy/issues/3960/declarative-backref-not-filtering-by
"the issue is somewhere in db.Model where their declarative base is interfering with declarative being able to set the "single inheritance" flag on the Event1 mapper."
The text was updated successfully, but these errors were encountered: