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
tests #12
Comments
As to the first one, I believe that is due to unpredictable ordering with dictionaries. Joins are stored using a dictionary, so whether it joins on Blog first or EntryTag first is up in the air -- this one is a bad test case. As to the count failure -- that's pretty odd. Looks like you're ending up with 2 extra entries per blog -- canyou do any more digging? |
Well it's not that simple. I spent some time on this - this seems really weird. There are 10 entries for blog in the database if I check. But somehow it seems to return 12 yes. As I said really odd. I will look into this as soon as I get some time. I want to help make this project better. |
While the one test failure is obnoxious (sql / dict ordering), I haven't been able to reproduce at all the other. Closing for now, but feel free to reopen if you come up w/any ideas. |
I'm encountering the same failure with To see what's happening, consider the test corresponding test code: # original from tests.py, line ~606
for blog in SelectQuery(Blog):
for i in xrange(20):
self.create_entry(title='entry%d' % i, blog=blog) There's an outer loop over the results of a select query and, within this loop, an inner loop that creates 20 Entry rows for the currently selected Blog row. The outer loop is lazy, however, which means the underlying SELECT statement is held open during the entire loop. This has an unfortunate interaction with the inner loop's autocommited INSERT. When The problem is that when certain versions of pysqlite commit a connection, they also reset all statements and cursors open on that connection. That means the SELECT statement behind the outer loop gets reset and replays the first two rows. (Why not just the first row? Because pysqlite fetches one row ahead; by the time the first line of the inner loop executes, the second blog row has already been fetched and so it, too, will get replayed.) Here are two possible workarounds: # fix 1: read blogs eagerly
for blog in list(SelectQuery(Blog)):
for i in xrange(20):
self.create_entry(title='entry%d' % i, blog=blog)
# fix 2: keep laziness but corral commit w/ explicit transaction
def create_blog_entries():
for blog in SelectQuery(Blog):
for i in xrange(20):
self.create_entry(title='entry%d' % i, blog=blog)
test_db.commit_on_success(create_blog_entries)() I hope that explanation makes sense. Cheers, P.S. As promised, here's the debug log that shows what statements get executed when the problem occurs. I've added annotations to make it easier to correlate the statements with the original test code.
|
Brilliant! I figured it went somewhere along those lines but could not figure out why just blog 0 & 1 were duplicated -- thank you for the report, it was educational! |
per your suggestion, eb91835 |
I thought it was something special to do with sqlite but could never figure this out. Thank you very much for explaining this. |
@tmoertel's comment did the trick for me. Thank you. |
I sometimes get the following Failure:
And always this one:
I'm already working on these - but these seme really ODD actually. There is something interesting going on at this
Which outputs:
The text was updated successfully, but these errors were encountered: