On 9/8/15 6:00 AM, Piotr Dobrogost wrote:
Hi!
In the FAQ there's entry titled "I’m getting a warning or error about
“Implicitly combining column X under attribute Y”" with the following
example:
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
class B(A):
__tablename__ = 'b'
# probably not what you want, but this is a demonstration
id = column_property(Column(Integer, primary_key=True), A.id)
a_id = Column(Integer, ForeignKey('a.id'))
However trying to add yet another class just to see what happens...
class C(B):
__tablename__ = 'c'
id = column_property(Column(Integer, primary_key=True), B.id)
b_id = Column(Integer, ForeignKey('b.id'))
...results in the same kind of error again:
"sqlalchemy.exc.InvalidRequestError: Implicitly combining column b.id
with column a.id under attribute 'id'. Please configure one or more
attributes for these same-named columns explicitly."
How to avoid this?
Place each column explicitly under the attribute that you want; B.id
does not expand into "B.id, A.id" automatically here:
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
class B(A):
__tablename__ = 'b'
id = column_property(Column(Integer, primary_key=True), A.id)
a_id = Column(Integer, ForeignKey('a.id'))
class C(B):
__tablename__ = 'c'
id = column_property(Column(Integer, primary_key=True), B.id, A.id)
b_id = Column(Integer, ForeignKey('b.id'))
ps.
This is a follow-up to my recent post
https://groups.google.com/forum/#!topic/sqlalchemy/n_JEgKYshnE
--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.