-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-101693: In sqlite3, deprecate using named placeholders with parameters supplied as a sequence #101698
Changes from 12 commits
b693895
483e4d6
e826428
132a6ee
31cc188
660a742
a18d0bb
3f94201
997ccc6
cb091af
450cdcc
841e8a4
3e7b680
38d1110
cf3cfc8
1687b65
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1435,13 +1435,24 @@ Cursor objects | |||||
| :raises ProgrammingError: | ||||||
| If *sql* contains more than one SQL statement. | ||||||
|
|
||||||
| :raises DeprecationWarning: | ||||||
| If :ref:`named placeholders <sqlite3-placeholders>` are used | ||||||
| and *parameters* is a sequence instead of a :class:`dict`. | ||||||
|
|
||||||
| If :attr:`~Connection.autocommit` is | ||||||
| :data:`LEGACY_TRANSACTION_CONTROL`, | ||||||
| :attr:`~Connection.isolation_level` is not ``None``, | ||||||
| *sql* is an ``INSERT``, ``UPDATE``, ``DELETE``, or ``REPLACE`` statement, | ||||||
| and there is no open transaction, | ||||||
| a transaction is implicitly opened before executing *sql*. | ||||||
|
|
||||||
| .. versionchanged:: 3.12 | ||||||
|
Member
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.
Suggested change
Contributor
Author
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. Are you sure about that? The API itself is not deprecated, we're just changing it. I'm not sure what's the recommended practice here.
Member
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. Yeah, I know what you mean. I feel like ideally this notice would be phrased along the lines of "X behaviour/practice is now deprecated" rather than "a DeprecationWarning is now emitted". That would be more to-the-point, and it would also work more naturally with this directive (X behaviour/practice is deprecated in 3.12, and will be removed entirely in 3.14). But I was struggling to come to with a concrete suggestion for how to reword these notices :/
Member
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. (The whatsnew and NEWS entries look great btw, it's just the notices in the API docs that feel slightly clunky to me)
Contributor
Author
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, but documented as deprecated and emitting a
Member
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. To your original question, btw: I think it's pretty standard to use
Contributor
Author
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. Aight! I'll try to reword it.
Contributor
Author
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. I've updated it to use |
||||||
|
|
||||||
| :exc:`DeprecationWarning` is raised | ||||||
| if | ||||||
| :ref:`named placeholders <sqlite3-placeholders>` are used | ||||||
| and *parameters* is a sequence. | ||||||
|
erlend-aasland marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| Use :meth:`executescript` to execute multiple SQL statements. | ||||||
|
|
||||||
| .. method:: executemany(sql, parameters, /) | ||||||
|
|
@@ -1465,6 +1476,10 @@ Cursor objects | |||||
| If *sql* contains more than one SQL statement, | ||||||
| or is not a DML statment. | ||||||
|
|
||||||
| :raises DeprecationWarning: | ||||||
| If :ref:`named placeholders <sqlite3-placeholders>` are used | ||||||
| and the items in *parameters* are sequences instead of :class:`dict`\s. | ||||||
|
|
||||||
| Example: | ||||||
|
|
||||||
| .. testcode:: sqlite3.cursor | ||||||
|
|
@@ -1476,6 +1491,12 @@ Cursor objects | |||||
| # cur is an sqlite3.Cursor object | ||||||
| cur.executemany("INSERT INTO data VALUES(?)", rows) | ||||||
|
|
||||||
| .. versionchanged:: 3.12 | ||||||
|
erlend-aasland marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| :exc:`DeprecationWarning` is raised if | ||||||
| :ref:`named placeholders <sqlite3-placeholders>` are used | ||||||
| and the items in *parameters* are sequences. | ||||||
|
|
||||||
| .. method:: executescript(sql_script, /) | ||||||
|
|
||||||
| Execute the SQL statements in *sql_script*. | ||||||
|
|
@@ -1971,7 +1992,7 @@ question marks (qmark style) or named placeholders (named style). | |||||
| For the qmark style, *parameters* must be a | ||||||
| :term:`sequence` whose length must match the number of placeholders, | ||||||
| or a :exc:`ProgrammingError` is raised. | ||||||
| For the named style, *parameters* should be | ||||||
| For the named style, *parameters* must be | ||||||
| an instance of a :class:`dict` (or a subclass), | ||||||
| which must contain keys for all named parameters; | ||||||
| any extra items are ignored. | ||||||
|
|
||||||
| 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.
Outdated
|
||
| 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. | ||
Uh oh!
There was an error while loading. Please reload this page.