I'm sure I'm doing something stupid, but I'm seeing SQLAlchemy+sqlite return a row that doesn't match the select condition.
-
I'm sure I'm doing something stupid, but I'm seeing SQLAlchemy+sqlite return a row that doesn't match the select condition. It is likely that SQLAlchemy is caching something, even though the session is fresh,
But the query is:
stmt = select(orm.Files).where(orm.Files.user == user and orm.Files.ontape == False).limit(1)and it's returning:
Files(user='someuser', uuid='1b9f0805-6587-46ba-a44d-df0e2a1654bb', name='filename', size=3181952, ontape=True)NEVER EVER should database software cache data at the start of a session. That's just wrong.
-
I'm sure I'm doing something stupid, but I'm seeing SQLAlchemy+sqlite return a row that doesn't match the select condition. It is likely that SQLAlchemy is caching something, even though the session is fresh,
But the query is:
stmt = select(orm.Files).where(orm.Files.user == user and orm.Files.ontape == False).limit(1)and it's returning:
Files(user='someuser', uuid='1b9f0805-6587-46ba-a44d-df0e2a1654bb', name='filename', size=3181952, ontape=True)NEVER EVER should database software cache data at the start of a session. That's just wrong.
@encthenet I don't think you can use Python's own `and` and `or` operators. I seem to remembee that that won't work as expected, and the manual doesn't mention their use. Either make two chained `.where()` calls, or import and use `and_()` and `or_()`.
-
R relay@relay.infosec.exchange shared this topic