Skip to content
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

sqlite3 doesn't have unit tests for 'insert or [algorithm]' functionality. #65449

Closed
AlexLordThorsen mannequin opened this issue Apr 16, 2014 · 7 comments
Closed

sqlite3 doesn't have unit tests for 'insert or [algorithm]' functionality. #65449

AlexLordThorsen mannequin opened this issue Apr 16, 2014 · 7 comments
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@AlexLordThorsen
Copy link
Mannequin

AlexLordThorsen mannequin commented Apr 16, 2014

BPO 21250
Nosy @ned-deily, @berkerpeksag, @raulcd
Files
  • sqlite_tests.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-09-06.23:07:57.597>
    created_at = <Date 2014-04-16.07:52:41.485>
    labels = ['tests', 'type-feature', 'library']
    title = "sqlite3 doesn't have unit tests for 'insert or [algorithm]' functionality."
    updated_at = <Date 2016-09-06.23:07:57.595>
    user = 'https://bugs.python.org/AlexLordThorsen'

    bugs.python.org fields:

    activity = <Date 2016-09-06.23:07:57.595>
    actor = 'berker.peksag'
    assignee = 'ghaering'
    closed = True
    closed_date = <Date 2016-09-06.23:07:57.597>
    closer = 'berker.peksag'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2014-04-16.07:52:41.485>
    creator = 'Alex.LordThorsen'
    dependencies = []
    files = ['39052']
    hgrepos = []
    issue_num = 21250
    keywords = ['patch']
    message_count = 7.0
    messages = ['216448', '216538', '216580', '241160', '268364', '274658', '274659']
    nosy_count = 6.0
    nosy_names = ['ghaering', 'ned.deily', 'python-dev', 'berker.peksag', 'Alex.LordThorsen', 'raulcd']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21250'
    versions = ['Python 3.5', 'Python 3.6']

    @AlexLordThorsen
    Copy link
    Mannequin Author

    AlexLordThorsen mannequin commented Apr 16, 2014

    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.

    @AlexLordThorsen AlexLordThorsen mannequin added tests Tests in the Lib/test dir type-feature A feature request or enhancement labels Apr 16, 2014
    @ned-deily
    Copy link
    Member

    Are you interested in submitting a patch?

    @AlexLordThorsen
    Copy link
    Mannequin Author

    AlexLordThorsen mannequin commented Apr 16, 2014

    Yes, I'm going to work on one after I fix bpo-16864 today.

    @AlexLordThorsen
    Copy link
    Mannequin Author

    AlexLordThorsen mannequin commented Apr 15, 2015

    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.

    @AlexLordThorsen AlexLordThorsen mannequin added the stdlib Python modules in the Lib dir label Apr 15, 2015
    @ghaering ghaering mannequin self-assigned this Aug 19, 2015
    @berkerpeksag
    Copy link
    Member

    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)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 6, 2016

    New changeset 91d3022b3f03 by Berker Peksag in branch '3.5':
    Issue bpo-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 bpo-21250: Merge from 3.5
    https://hg.python.org/cpython/rev/db2bedd5c34a

    @berkerpeksag
    Copy link
    Member

    Thanks for the patch, Alex!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants