Hi listmembers,
i have a problem with a difference i find playing with sqla between
query.count and query.all results.
I have a parent class declaratively mapped to a table in MySQL, there
is a child class with a relationship.
I'm not sure how to create a quick session (i suspect a problem lies
there, but i have no clue) - my usecase is very general, but i am not
sure if i have the lingo right (been reading the docs till blue in the
face, didn't know using this wonderful stuff is so intricate).
In short i use the following, (productdescriptions depending on
languages):
Session = scoped_session(sessionmaker())
session = Session(autoflush=True)
class Products(Base):
products_id = Column(Integer, primary_key=True)
products_loc = Column(String)
product_descriptions = relationship("Products_description",
cascade="all",
backref=backref('product'))
class Products_description(Base):
products_description_id = Column(Integer, primary_key=True)
products_id = Column(Integer, ForeignKey('products.products_id'),
nullable=False)
language_id = Column(Integer, ForeignKey('languages.languages_id'),
nullable=False)
class Languages(Base):
languages_id = Column(Integer, primary_key=True)
etc..
I would expect the product_descriptions to hold two objects if there
are two records in de database (for two languages, but that is
irrelevant here .. or is it?), related via the products_id attribute.
When i query the database like so:
qry =
session.query(Products_description).join(Products).filter(Products_descri
ption.products_id == :someniceproducts_id)
with some nice existing products_id
qry.count() results in 2L (like i would expect, there being two
description records in the db for the product)
but when i issue:
qry.all()
i only get one object as a result.
I clearly - after studying the docs - don't understand sqlalchemy at
all :)
What am i doing wrong? it looks so easy and straightforward that i find
myself checking my chair twice to be sure it's there before sitting
down (..).
Can somebody please HELP me :)
Cheers
Freddy
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.