-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-34041: Added *deterministic* parameter to sqlite3.Connection.create_function(). #8086
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
Changes from all commits
3ea174a
d854d91
5c8a67b
dcb8e51
25952a3
1473689
faf9b6b
0bfe04a
33f8e64
0dcc22c
dc8ca8d
b7d928a
3115324
130cb5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
# 3. This notice may not be removed or altered from any source distribution. | ||
|
||
import unittest | ||
import unittest.mock | ||
import sqlite3 as sqlite | ||
|
||
def func_returntext(): | ||
|
@@ -275,6 +276,28 @@ def CheckAnyArguments(self): | |
val = cur.fetchone()[0] | ||
self.assertEqual(val, 2) | ||
|
||
def CheckFuncNonDeterministic(self): | ||
mock = unittest.mock.Mock(return_value=None) | ||
self.con.create_function("deterministic", 0, mock, deterministic=False) | ||
self.con.execute("select deterministic() = deterministic()") | ||
self.assertEqual(mock.call_count, 2) | ||
|
||
@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "deterministic parameter not supported") | ||
def CheckFuncDeterministic(self): | ||
mock = unittest.mock.Mock(return_value=None) | ||
self.con.create_function("deterministic", 0, mock, deterministic=True) | ||
self.con.execute("select deterministic() = deterministic()") | ||
self.assertEqual(mock.call_count, 1) | ||
|
||
@unittest.skipIf(sqlite.sqlite_version_info >= (3, 8, 3), "SQLite < 3.8.3 needed") | ||
def CheckFuncDeterministicNotSupported(self): | ||
with self.assertRaises(sqlite.NotSupportedError): | ||
self.con.create_function("deterministic", 0, int, deterministic=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add a simple test to make sure that self.con.create_function("deterministic", 0, int, True) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in the following test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, just pushed the fix. |
||
|
||
def CheckFuncDeterministicKeywordOnly(self): | ||
with self.assertRaises(TypeError): | ||
self.con.create_function("deterministic", 0, int, True) | ||
|
||
|
||
class AggregateTests(unittest.TestCase): | ||
def setUp(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add the parameter *deterministic* to the | ||
:meth:`sqlite3.Connection.create_function` method. Patch by Sergey Fedoseev. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest add a link to the
NotSupportedError
documentation, then I noticed it wasn't documented. I've opened https://bugs.python.org/issue34061