Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuple comparison with ">=" is broken #663

Open
nielstron opened this issue Sep 19, 2022 · 0 comments
Open

Tuple comparison with ">=" is broken #663

nielstron opened this issue Sep 19, 2022 · 0 comments

Comments

@nielstron
Copy link

nielstron commented Sep 19, 2022

In the case if ">=", the translation of tuple comparison is wrong. The correct translation of (a, b) >= (c, d) is a __>__ c OR (a = c AND b > d). However, currently it is a __>=__ c OR (a = c AND b > d).

Consider the following sample program:

from pony import orm as pony

DB_NAME = "test.sqlite"
db = pony.Database()

class Test(db.Entity):
    a = pony.Required(int)
    b = pony.Required(int)


db.bind(provider="sqlite", filename=DB_NAME, create_db=True)
db.generate_mapping(create_tables=True)
pony.set_sql_debug(True)

with pony.db_session as ses:
    _ = pony.get(f for f in Test if (f.a, f.b) >= (1, 2))

with this output:

GET NEW CONNECTION
SWITCH TO AUTOCOMMIT MODE
SELECT "f"."id", "f"."a", "f"."b"
FROM "Test" "f"
WHERE ("f"."a" >= 1 OR "f"."a" = 1 AND "f"."b" >= 2)
LIMIT 2

RELEASE CONNECTION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant