raise exception when calling one() or first() when limit() has already been applied

Issue #1422 resolved
Former user created an issue

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)

  1. Former user 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

  2. Former user 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

  3. Mike Bayer repo owner

    this ticket is more or less a dupe of #1688 which has been fixed, one() now doesn't use limit at all, and the original test here works as expected.

  4. Log in to comment