This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sqlite3 doesn't have unit tests for 'insert or [algorithm]' functionality.
Type: enhancement Stage: resolved
Components: Library (Lib), Tests Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ghaering Nosy List: Alex.LordThorsen, berker.peksag, ghaering, ned.deily, python-dev, raulcd
Priority: normal Keywords: patch

Created on 2014-04-16 07:52 by Alex.LordThorsen, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sqlite_tests.patch Alex.LordThorsen, 2015-04-15 21:08
Messages (7)
msg216448 - (view) Author: Alex LordThorsen (Alex.LordThorsen) * Date: 2014-04-16 07:52
In Lib/sqlite3/tests/dbapi.py there are no unit tests which test out sqlite3's 'insert or [algorithm].' These algorithms are also referred to as SQL 'insert on conflict.'

More details at,
https://www.sqlite.org/lang_conflict.html

Not having unit tests for these features, especially 'insert or rollback,' seems like an easy way for timing and threading bugs to get lost in the database api.
msg216538 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-04-16 18:16
Are you interested in submitting a patch?
msg216580 - (view) Author: Alex LordThorsen (Alex.LordThorsen) * Date: 2014-04-16 20:23
Yes, I'm going to work on one after I fix Issue16864 today.
msg241160 - (view) Author: Alex LordThorsen (Alex.LordThorsen) * Date: 2015-04-15 21:08
I've added a set of tests which test the insert or [algorithm] branch of sqlite. It took some getting used to python.sqlite3's transaction model but I think I have a much better understanding now.
msg268364 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-12 11:21
Thanks for the patch Alex. Some quick review comments:

* We need to skip SqliteOnConflictTests if the installed sqlite3 doesn't support the feature

* There is no need to duplicate https://www.sqlite.org/lang_conflict.html in every test. You can add it to SqliteOnConflictTests docstring.

* Instead of ``try: <something> except sqlite.IntegrityError: <pass>`` we can make sure that sqlite.IntegrityError is raised by using assertRaises (like you did in CheckOnConflictFail.)

* The following pattern can be replaced with a list comprehension:

  +        returned_rows = []
  +        for row in self.cu:
  +            returned_rows.append(row)
msg274658 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-06 23:05
New changeset 91d3022b3f03 by Berker Peksag in branch '3.5':
Issue #21250: Add tests for SQLite's ON CONFLICT clause
https://hg.python.org/cpython/rev/91d3022b3f03

New changeset db2bedd5c34a by Berker Peksag in branch 'default':
Issue #21250: Merge from 3.5
https://hg.python.org/cpython/rev/db2bedd5c34a
msg274659 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-06 23:07
Thanks for the patch, Alex!
History
Date User Action Args
2022-04-11 14:58:01adminsetgithub: 65449
2016-09-06 23:07:57berker.peksagsetstatus: open -> closed
resolution: fixed
messages: + msg274659

stage: patch review -> resolved
2016-09-06 23:05:14python-devsetnosy: + python-dev
messages: + msg274658
2016-06-12 11:21:08berker.peksagsetversions: + Python 3.6, - Python 2.7, Python 3.4
nosy: + berker.peksag

messages: + msg268364

stage: needs patch -> patch review
2015-08-19 09:56:18ghaeringsetassignee: ghaering
2015-04-16 15:57:00raulcdsetnosy: + raulcd
2015-04-15 21:09:03Alex.LordThorsensetcomponents: + Library (Lib)
2015-04-15 21:08:22Alex.LordThorsensetfiles: + sqlite_tests.patch
keywords: + patch
messages: + msg241160
2014-04-16 20:23:31Alex.LordThorsensetmessages: + msg216580
2014-04-16 18:16:38ned.deilysetversions: - Python 3.1, Python 3.2, Python 3.3
nosy: + ghaering, ned.deily

messages: + msg216538

stage: needs patch
2014-04-16 07:52:41Alex.LordThorsencreate