Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-101693: In sqlite3, deprecate using named placeholders with parameters supplied as a sequence#101698
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
gh-101693: In sqlite3, deprecate using named placeholders with parameters supplied as a sequence#101698
Changes from1 commit
b693895483e4d6e826428132a6ee31cc188660a742a18d0bb3f94201997ccc6cb091af450cdcc841e8a43e7b68038d1110cf3cfc81687b65File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -415,6 +415,13 @@ Deprecated | ||
| and tailor them to your needs. | ||
| (Contributed by Erlend E. Aasland in :gh:`90016`.) | ||
| * In :meth:`~sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now raised | ||
AlexWaygood marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| when :ref:`named placeholders <sqlite3-placeholders>` are used together with | ||
| parameters supplied as a :term:`sequence`. | ||
| Starting from Python 3.14, using named placeholders with parameters supplied | ||
| as a sequence will raise a :exc:`~sqlite3.ProgrammingError`. | ||
| (Contributed by Erlend E. Aasland in :gh:`101698`.) | ||
| * The 3-arg signatures (type, value, traceback) of :meth:`~coroutine.throw`, | ||
| :meth:`~generator.throw` and :meth:`~agen.athrow` are deprecated and | ||
| may be removed in a future version of Python. Use the single-arg versions | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -861,6 +861,20 @@ def __getitem__(slf, x): | ||
| with self.assertRaises(ZeroDivisionError): | ||
| self.cu.execute("select name from test where name=?", L()) | ||
| def test_execute_named_param_and_sequence(self): | ||
| dataset = ( | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| ("select :a", (1,)), | ||
| ("select :a, ?, ?", (1, 2, 3)), | ||
| ("select ?, :b, ?", (1, 2, 3)), | ||
| ("select ?, ?, :c", (1, 2, 3)), | ||
| ) | ||
| msg = "Binding.*is a named parameter" | ||
| for query, params in dataset: | ||
| with self.subTest(query=query, params=params): | ||
| with self.assertWarnsRegex(DeprecationWarning, msg) as cm: | ||
| self.cu.execute(query, params) | ||
| self.assertEqual(cm.filename, __file__) | ||
| def test_execute_too_many_params(self): | ||
| category = sqlite.SQLITE_LIMIT_VARIABLE_NUMBER | ||
| msg = "too many SQL variables" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| In:meth:`sqlite3.Cursor.execute`,:exc:`DeprecationWarning` is now raised | ||
AlexWaygood marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| when:ref:`named placeholders<sqlite3-placeholders>` are used together with | ||
| parameters supplied as a:term:`sequence`. | ||
| Starting from Python 3.14, using named placeholders with parameters supplied | ||
| as a sequence will raise a:exc:`~sqlite3.ProgrammingError`. | ||
| Patch by Erlend E. Aasland. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -662,6 +662,17 @@ bind_parameters(pysqlite_state *state, pysqlite_Statement *self, | ||
| return; | ||
| } | ||
| for (i = 0; i < num_params; i++) { | ||
| const char *name = sqlite3_bind_parameter_name(self->st, i+1); | ||
| if (name != NULL) { | ||
| PyErr_WarnFormat(PyExc_DeprecationWarning, 1, | ||
erlend-aasland marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| "Binding %d ('%s') is a named parameter, " | ||
| "but you supplied a sequence which requires " | ||
| "nameless (qmark) placeholders. " | ||
| "Starting with Python 3.14 an " | ||
| "sqlite3.ProgrammingError will be raised.", | ||
| i+1, name); | ||
| } | ||
| if (PyTuple_CheckExact(parameters)) { | ||
| PyObject *item = PyTuple_GET_ITEM(parameters, i); | ||
| current_param = Py_NewRef(item); | ||