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
test_sqlite: CheckFuncDeterministic() fails with SQLite 3.32 #84961
Comments
With SQLite 3.32, test_sqlite fails with: FAIL: CheckFuncDeterministic (sqlite3.test.userfunctions.FunctionTests) Traceback (most recent call last):
File "/builddir/build/BUILD/Python-3.9.0b1/Lib/sqlite3/test/userfunctions.py", line 290, in CheckFuncDeterministic
self.assertEqual(mock.call_count, 1)
AssertionError: 2 != 1 This test defines a "deterministic" function and ensures that calling it twice in SQLite with only call the underyling Python function only once. Copy of the test:
In pysqlite_connection_create_function() of Modules/_sqlite/connection.c, determistic=1 sets the following flag:
This flag is documented as: "SELECT 1 WHERE deterministic() = deterministic()" query also calls the mock twice. Running "SELECT deterministic()" query twice also calls the mock twice. It seems like SQLite 3.32 behaves differently. Fedora issue: https://bugzilla.redhat.com/show_bug.cgi?id=1839826 |
Oh, I also tried with a function taking one argument and then call it twice by running "SELECT deterministic(1)" query twice: again, the mock is also called twice. |
This seems like it's testing an implementation detail. |
Indeed. The SQLite documentation talks about the limitations that non-deterministic functions have, not about deterministic functions being memoized: https://www.sqlite.org/deterministic.html The flag would be better tested e.g. with a CHECK constraint: https://www.sqlite.org/lang_createtable.html#ckconst |
Hi, folks. I took the liberty to create a PR for this; hope you don't mind. I've used partial indices to test deterministic behaviour. |
Python 3.8 and Python 3.9 are also affected, I created backports. Python 3.7 is not affected: deterministic parameter was added to Python 3.8. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: