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

Weird way of case-insensitive indexing of sqlite3.Row #82366

Closed
serhiy-storchaka opened this issue Sep 16, 2019 · 4 comments
Closed

Weird way of case-insensitive indexing of sqlite3.Row #82366

serhiy-storchaka opened this issue Sep 16, 2019 · 4 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 38185
Nosy @berkerpeksag, @serhiy-storchaka, @miss-islington
PRs
  • bpo-38185: Fixed case-insensitive string comparison in sqlite3.Row indexing. #16190
  • [3.8] bpo-38185: Fixed case-insensitive string comparison in sqlite3.Row indexing. (GH-16190) #16216
  • [3.7] bpo-38185: Fixed case-insensitive string comparison in sqlite3.Row indexing. (GH-16190) #16217
  • 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 2019-09-17.09:37:40.032>
    created_at = <Date 2019-09-16.10:00:11.887>
    labels = ['3.7', '3.8', 'type-bug', 'library', '3.9']
    title = 'Weird way of case-insensitive indexing of sqlite3.Row'
    updated_at = <Date 2019-09-17.09:37:40.032>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2019-09-17.09:37:40.032>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-17.09:37:40.032>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2019-09-16.10:00:11.887>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38185
    keywords = ['patch']
    message_count = 4.0
    messages = ['352533', '352604', '352611', '352612']
    nosy_count = 4.0
    nosy_names = ['ghaering', 'berker.peksag', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['16190', '16216', '16217']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38185'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    @serhiy-storchaka
    Copy link
    Member Author

    sqlite3.Row can be indexed by integers and by strings. In the latter case string matching is case insensitive. But the code that implements this is too simple-minded. It compares UTF-8 representation of two strings ignoring some bit. It works for ASCII letters, but has weird behavior for digits, '_' and non-ASCII characters.

    For example:

    >>> import sqlite3
    >>> con = sqlite3.connect(":memory:")
    >>> con.row_factory = sqlite3.Row
    >>> row = con.execute("select 1 as a_1").fetchone()
    >>> row['a_1']
    1
    >>> row['A_1']
    1
    >>> row['A_\x11']
    1
    >>> row['A\x7f1']
    1
    >>> row = con.execute("select 1 as ÿ").fetchone()
    >>> row["ÿ"]
    1
    >>> row["Ÿ"]
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    IndexError: No item with that key
    >>> row["ß"]
    1

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 16, 2019
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset f669581 by Serhiy Storchaka in branch 'master':
    bpo-38185: Fixed case-insensitive string comparison in sqlite3.Row indexing. (GH-16190)
    f669581

    @miss-islington
    Copy link
    Contributor

    New changeset d8d653c by Miss Islington (bot) in branch '3.8':
    bpo-38185: Fixed case-insensitive string comparison in sqlite3.Row indexing. (GH-16190)
    d8d653c

    @miss-islington
    Copy link
    Contributor

    New changeset 80cb055 by Miss Islington (bot) in branch '3.7':
    bpo-38185: Fixed case-insensitive string comparison in sqlite3.Row indexing. (GH-16190)
    80cb055

    @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
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants