- marked as major
- changed component to orm
- changed title to raise exception when calling one() or first() when limit() has already been applied
- changed milestone to 0.5.5
raise exception when calling one() or first() when limit() has already been applied
Hello everyone,
I'm running 0.5.4p1.
Fetching data with .limit(1).all() or .limit(1).first() correctly generates: LIMIT 1 OFFSET 0
Fetching the same data with .limit(1) and .one() however generates LIMIT 2 OFFSET 0 and raises an sqlalchemy.orm.exc.MultipleResultsFound exception respectively.
I have successfully verified this with MySQL and SQLite and therefore assume this issue to be dialect-independent.
You may use the attached file to verify my findings.
Best Regards, Thomas Wiebe
Comments (6)
-
repo owner -
Account Deleted Hello Michael,
I won't use one() in that case then. But apparently I also didn't catch every aspect of the misbehaviour before: The effect seems to occur with one() in general I have attached another test file to demonstrate other scenarios that generate incorrect LIMIT statements with 0.5.4p1.
Best Regards, Thomas Wiebe
-
Account Deleted Darn, it's pretty early in the morning. No coffee yet. Please forget my whole last post and 2nd attachment. Of course you would LIMIT 2 in order to raise MultipleResultsFound wherever necessary. We are talking about one() here, not limit(1).
Damn you defective coffee maker.
Best, Thomas
-
repo owner - changed milestone to 0.5.xx
-
repo owner this ticket is more or less a dupe of
#1688which has been fixed,one()
now doesn't use limit at all, and the original test here works as expected. -
repo owner - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
the bug is that an exception is not raised when two operations with conflicting limits are called. to get the results you want, call limit(1).from_self().one().