Commit Graph

48 Commits

Author SHA1 Message Date
Miss Islington (bot) 6dcbd50eb8
[3.11] gh-105557: Remove duplicate sqlite3 test method (GH-105558) (#105562)
test_func_return_too_large_int() was defined twice.
Keep only the redefined method, as that also checks the tracebacks.
(cherry picked from commit b8fa7bda4f)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 14:02:15 +00:00
Erlend E. Aasland 681d5028bd
[3.11] gh-100370: fix OverflowError in sqlite3.Connection.blobopen for 32-bit builds (#103902) (#104285) 2023-05-08 08:41:34 +00:00
Miss Islington (bot) b9304beda0
gh-101947: Remove size check from sqlite3 serialize test (GH-102914)
The size of the returned data is too implementation specific.
(cherry picked from commit 61405da9a5)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-03-22 06:45:28 -07:00
Miss Islington (bot) fba8c7cf74
gh-100553: Improve accuracy of sqlite3.Row iter test (GH-100555)
(cherry picked from commit 3dc48dabd4)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-12-27 17:25:28 -08:00
Ken Jin 9e38553132
[3.11] gh-99886: Fix crash when freeing objects with managed dictionaries (#99902)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2022-12-04 14:41:23 +08:00
Miss Islington (bot) e26aa24b47
gh-99659: Use correct exceptions in sqlite3 bigmem tests (GH-99660)
The tests in question were added in 0eec6276fd by Serhiy. Apparently,
sqlite3 changed exceptions raised in those cases in the mean time but
the tests never ran because they require a high `-M` setting in the
test runner.
(cherry picked from commit 2781ec9b0e)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-11-22 00:51:59 -08:00
Erlend Egeberg Aasland 5d3f2fbf37
[3.11] gh-95132: Correctly relay *args and **kwds from sqlite3.connect to factory (GH-95146) (#95158)
This PR partially reverts gh-24421 (PR) and fixes the remaining concerns
given in gh-93044 (issue):

- keyword arguments are passed as positional arguments to factory()
- if an argument is not passed to sqlite3.connect(), its default value
  is passed to factory()

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>.
(cherry picked from commit a3d4d15f53)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2022-07-23 10:23:19 +02:00
Miss Islington (bot) 2ac1096423
gh-94998: Remove redundant condition in test_sqlite3/__main__.py (GH-95052)
(cherry picked from commit 9d09e7b026)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
2022-07-20 10:01:58 -07:00
Christian Heimes cf3f8d4728
[3.11] gh-84461: Fix test_sqlite for Emscripten/WASI (GH-94125) (GH-94157)
(cherry picked from commit 15bfabd1aa)

Co-authored-by: Christian Heimes <christian@python.org>
2022-06-23 03:11:35 -07:00
Miss Islington (bot) b4ebde429e
gh-94028: Clear and reset sqlite3 statements properly in cursor iternext (GH-94042)
(cherry picked from commit 94eeac03dc)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
2022-06-21 04:52:47 -07:00
Miss Islington (bot) 5abe4cbe88
gh-79009: sqlite3.iterdump now correctly handles tables with autoincrement (GH-9621)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
(cherry picked from commit affa9f22cf)

Co-authored-by: itssme <itssme3000@gmail.com>
2022-06-19 16:25:13 -07:00
Erlend Egeberg Aasland 7aa4038a6e
[3.11] gh-93795: Use test.support TESTFN/unlink in sqlite3 tests (GH-93796) (#93808) 2022-06-14 17:41:32 +02:00
Erlend Egeberg Aasland 871b1dc469
[3.11] gh-79579: Improve DML query detection in sqlite3 (GH-93623) (#93800)
The fix involves using pysqlite_check_remaining_sql(), not only to check
for multiple statements, but now also to strip leading comments and
whitespace from SQL statements, so we can improve DML query detection.

pysqlite_check_remaining_sql() is renamed lstrip_sql(), to more
accurately reflect its function, and hardened to handle more SQL comment
corner cases.
(cherry picked from commit 46740073ef)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
2022-06-14 14:49:22 +02:00
Miss Islington (bot) 68aae80159
gh-93421: Update sqlite3 cursor.rowcount only after SQLITE_DONE (GH-93526)
(cherry picked from commit 875de61c29)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
2022-06-08 04:07:15 -07:00
Miss Islington (bot) acc998a831
GH-93115: Fix version check in sqlite3 module constants test (GH-93116)
(cherry picked from commit d5f0dd1600)

Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-05-23 09:35:13 -07:00
Miss Islington (bot) 748c83d96d
Clean up the sqlite3 tests (GH-93056)
Remove helper managed_connect(). Use memory_database() or
contextlib.closing() + addCleanup(unlink) instead.
(cherry picked from commit e5d8dbdd30)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-21 09:37:04 -07:00
Miss Islington (bot) 76b6ed17ea
Improve tests for opening Sqlite by URI (GH-93047)
* Test with with escaped non-ascii characters
* Test read-only open of existing DB.
(cherry picked from commit 4e2b664892)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-21 08:05:13 -07:00
Serhiy Storchaka d9a48d2b41
[3.11] gh-93044: No longer convert the database argument of sqlite3.connect() to bytes (GH-93046) (GH-93048)
Just pass it to the factory as is.
(cherry picked from commit 14c0d33016)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-21 16:53:58 +03:00
Miss Islington (bot) 6ec050f633
gh-91922: Fix sqlite connection on nonstardard locales and paths (GH-92926)
(cherry picked from commit d853758092)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-20 02:42:48 -07:00
Erlend Egeberg Aasland 090819ec5f
gh-89022: Improve sqlite3 exceptions related to binding params and API misuse (#91572)
* Map SQLITE_MISUSE to sqlite3.InterfaceError

SQLITE_MISUSE implies misuse of the SQLite C API, which, if it happens,
is _not_ a user error; it is an sqlite3 extension module error.

* Raise better errors when binding parameters fail.

Instead of always raising InterfaceError, guessing what went wrong,
raise accurate exceptions with more accurate error messages.
2022-05-04 07:16:01 -06:00
Erlend Egeberg Aasland f629dcfe83
gh-80254: Disallow recursive usage of cursors in `sqlite3` converters (#29054)
Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-03 17:03:06 -06:00
Erlend Egeberg Aasland 721aa96540
gh-89301: Fix regression with bound values in traced SQLite statements (#92053) 2022-05-02 08:14:35 -06:00
Erlend Egeberg Aasland 9ea9078ec7
gh-92019: Make sqlite3.Blob indexing conform with the norm (#92020)
- get index now returns an int
- set index now requires an int in range(0, 256)

Resolves #92019
2022-04-30 09:01:37 -06:00
Erlend Egeberg Aasland 29afb7d2ef
gh-69093: Add indexing and slicing support to sqlite3.Blob (#91599)
Authored-by: Aviv Palivoda <palaviv@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@innova.no>
2022-04-21 18:45:16 -07:00
Erlend Egeberg Aasland a861756675
gh-69093: Add context manager support to sqlite3.Blob (GH-91562) 2022-04-15 21:21:12 -07:00
Erlend Egeberg Aasland d104f4d21f
gh-69093: Don't allow instantiation of sqlite3.Blob objects (GH-91570) 2022-04-15 09:25:03 -07:00
Jelle Zijlstra b7f83bdd0e
gh-69093: Expose sqlite3.Blob as a class (GH-91550)
I noticed this was missing while writing typeshed stubs. It's
useful to expose it for use in annotations and for exploration.
2022-04-15 06:29:57 -07:00
Erlend Egeberg Aasland ee475430d4
gh-69093: Support basic incremental I/O to blobs in `sqlite3` (GH-30680)
Authored-by: Aviv Palivoda <palaviv@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@innova.no>
Co-authored-by: palaviv <palaviv@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-14 17:02:56 -07:00
Erlend Egeberg Aasland 9ebcece82f
gh-79097: Add support for aggregate window functions in sqlite3 (GH-20903) 2022-04-11 17:55:59 -07:00
Erlend Egeberg Aasland a7551247e7
bpo-41930: Add support for SQLite serialise/deserialise API (GH-26728)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-04-05 07:15:25 -07:00
Erlend Egeberg Aasland 4674fd4e93
bpo-44859: Raise more accurate exceptions in `sqlite3` (GH-27695)
* Improve exception compliance with PEP 249
* Raise InterfaceError instead of ProgrammingError for SQLITE_MISUSE.
  If SQLITE_MISUSE is raised, it is a sqlite3 module bug. Users of the
  sqlite3 module are not responsible for using the SQLite C API correctly.
* Don't overwrite BufferError with ValueError when conversion to BLOB fails.
* Raise ProgrammingError instead of Warning if user tries to execute() more
  than one SQL statement.
* Raise ProgrammingError instead of ValueError if an SQL query contains null characters.
* Make sure `_pysqlite_set_result` raises an exception if it returns -1.
2022-03-16 22:58:25 -07:00
Erlend Egeberg Aasland e801e88744
bpo-45138: Revert GH-28240: Expand traced SQL statements (GH-31788)
This reverts commit d1777515f9.

Automerge-Triggered-By: GH:JelleZijlstra
2022-03-09 09:39:49 -08:00
Erlend Egeberg Aasland d1777515f9
bpo-45138: Expand traced SQL statements in `sqlite3` trace callback (GH-28240) 2022-03-08 18:46:40 -08:00
Erlend Egeberg Aasland 88567a9970
bpo-46874: Speed up sqlite3 user-defined aggregate 'step' method (GH-31604) 2022-03-03 22:54:36 +09:00
Erlend Egeberg Aasland 3eb3b4f270
bpo-43853: Expand test suite for SQLite UDF's (GH-27642) 2022-01-26 08:26:16 -08:00
Nikita Sobolev 55f4ec460e
bpo-46425: use absolute imports in `test_sqlite3` (GH-30676) 2022-01-22 18:03:56 +02:00
Erlend Egeberg Aasland 9d6a239a34
bpo-44092: Don't reset statements/cursors before rollback (GH-26026)
In SQLite versions pre 3.7.11, pending statements would block a rollback.  This is no longer the case, so remove the workaround.
2022-01-03 19:02:39 +00:00
Erlend Egeberg Aasland c4a69a4ad0
bpo-45828: Use unraisable exceptions within sqlite3 callbacks (FH-29591) 2021-11-29 15:22:32 +00:00
Erlend Egeberg Aasland 5f9247e36a
bpo-45512: Extend `sqlite3` test suite regarding isolation levels (GH-29576) 2021-11-17 19:01:54 +09:00
Erlend Egeberg Aasland 9d6215a54c
bpo-45126: Harden `sqlite3` connection initialisation (GH-28227) 2021-11-16 15:53:35 +01:00
Erlend Egeberg Aasland 822c3dcce3
bpo-45512: Raise exception if sqlite3.Connection.__init__ is called with bad isolation level (#29561)
* bpo-45512: Raise sqlite3.Connection.__init__ is called with bad isolation level

* Also explicitly test allowed isolation levels

* Use subTest for better error messages if something goes wrong

* Update Lib/test/test_sqlite3/test_dbapi.py

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2021-11-15 21:55:38 +09:00
Erlend Egeberg Aasland c1323d4b8c
bpo-45754: Use correct SQLite limit when checking statement length (GH-29489) 2021-11-10 18:46:11 +00:00
Erlend Egeberg Aasland 3d42cd9461
bpo-45243: Use connection limits to simplify `sqlite3` tests (GH-29356) 2021-11-05 19:19:43 +02:00
Erlend Egeberg Aasland c273986711
bpo-45613: Set `sqlite3.threadsafety` dynamically (GH-29227)
Use the compile-time selected default SQLite threaded mode to set the
DB-API 2.0 attribute 'threadsafety'

Mappings:
  - SQLITE_THREADSAFE=0 => threadsafety=0
  - SQLITE_THREADSAFE=1 => threadsafety=3
  - SQLITE_THREADSAFE=2 => threadsafety=1
2021-11-03 21:01:37 +00:00
Erlend Egeberg Aasland 0dfb8c4afe
bpo-24139: Fix test_sqlite3 `test_extended_error_code_on_exception()` on s390x RHEL buildbots (GH-29382) 2021-11-03 17:35:42 +08:00
Erlend Egeberg Aasland 456e27ac0a
bpo-24139: Add support for SQLite extended result codes (GH-28076) 2021-11-02 23:49:38 +00:00
Erlend Egeberg Aasland b6b38a8226
bpo-45243: Add support for setting/getting `sqlite3` connection limits (GH-28463) 2021-11-01 22:50:53 +00:00
Erlend Egeberg Aasland 62bf263a77
bpo-10572: Move `sqlite3` tests to `Lib/test` (GH-29304)
Automerge-Triggered-By: GH:brettcannon
2021-10-29 15:08:19 -07:00