Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

Query.all() on changing tables #60

Closed Jaymon closed 3 years ago

Jaymon commented 6 years ago

When you want to pull every row one time on a table that is changing, Query.all() can sometimes give you unexpected behavior, I'm pretty sure this is related to the table changing and then all() getting the next tranche of results using LIMIT X OFFSET Y but the underlying table structure having changed.

To get around this it might be worth modifying all() or adding something like an every() that will sort by primary key ascending or descending and then keep track of what primary key was the last and then use that to get the next set of rows

To test this, you could add a bunch of rows, then you could have a thread that would change the db while the test is running through all the rows and make sure you see each row one time.

Jaymon commented 6 years ago

I wonder, could you wrap the query in a transaction to keep the table from changing for the life of the queries?