Hi,

after reading the docs [1] I thought that something like
session.query(User).filter(User.c.id > 3)[0]
should work even if the filter clause does not return any rows.

But - compliant with Python's behavior - SQLAlchemy raises an
IndexError.
(...)
   File "/usr/lib/python2.4/site-packages/sqlalchemy/orm/query.py", line 577, 
in __getitem__
     return list(self[item:item+1])[0]
IndexError: list index out of range
I expected that [0] applied to query without results would return None.

Did I miss another possibility for LIMIT'ing queries (using sqlalchemy.orm)?

fs

[1] http://www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_querying

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to