Hi all,
I was giving SQLAlchemy 1.0 series a try but I have found some problems
along
the way. There are some queries that in the 0.9.9 version used to work, but
they do not work as expected anymore. An example of one of those is:
feeds = DBSession.query(Feed, Client, ClientPro).outerjoin(
Client, Client.id == Feed.clientid).outerjoin(
ClientPro, ClientPro.clientid == Client.id)
and it used to return:
SELECT feed.id AS feed_id, feed.clientid AS feed_clientid ...
FROM feed
LEFT OUTER JOIN client ON client.id = feed.clientid
LEFT OUTER JOIN clientpro ON clientpro.clientid = client.id
But since I changed to 1.0 series it returns:
SELECT feed.id AS feed_id, feed.clientid ...
FROM feed
LEFT OUTER JOIN client ON client.id = feed.clientid AND NULL
LEFT OUTER JOIN clientpro ON clientpro.clientid = client.id AND NULL
As you can see, it adds the 'AND NULL' condition to the joins so the columns
corresponding to the client and clientpro are NULL.
I have tested it from version 1.0.0 to 1.0.5 and it returns the same SQL
query
in all of them.
The relevant part of the models.py file is:
class Feed(Base, ModelBase):
__tablename__ = 'feed'
id = Column(Integer, primary_key=True)
clientid = Column(Integer, ForeignKey('client.id'), nullable=False)
...
class Client(Base, ModelBase):
__tablename__ = 'client'
id = Column(Integer, primary_key=True)
...
class ClientPro(Base, ModelBase):
__tablename__ = 'clientpro'
id = Column(Integer, primary_key=True)
clientid = Column(Integer, ForeignKey('client.id', ondelete='CASCADE'),
nullable=False)
...
And finally, the versions I am using:
- PostgreSQL 9.3
- Pyramid 1.5.7 (zope.sqlalchemy 0.7.6)
- psycopg2 2.6
What it is that I am missing?
Thanks!
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.