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

SQLite returns "str" instead of "datetime.datetime" with aggregate queries. #85890

Closed
ravi-misra mannequin opened this issue Sep 5, 2020 · 8 comments
Closed

SQLite returns "str" instead of "datetime.datetime" with aggregate queries. #85890

ravi-misra mannequin opened this issue Sep 5, 2020 · 8 comments
Labels
3.8 expert-C-API type-bug

Comments

@ravi-misra
Copy link
Mannequin

@ravi-misra ravi-misra mannequin commented Sep 5, 2020

BPO 41724
Nosy @ericvsmith, @berkerpeksag, @serhiy-storchaka, @sblondon, @miss-islington, @sweeneyde, @ravi-misra
PRs
  • #23855
  • #23862
  • #23863
  • Files
  • reproducer.py
  • 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 2020-12-20.00:03:47.308>
    created_at = <Date 2020-09-05.06:23:53.252>
    labels = ['expert-C-API', 'type-bug', '3.8']
    title = 'SQLite returns "str" instead of "datetime.datetime" with aggregate queries.'
    updated_at = <Date 2020-12-20.00:03:47.307>
    user = 'https://github.com/ravi-misra'

    bugs.python.org fields:

    activity = <Date 2020-12-20.00:03:47.307>
    actor = 'eric.smith'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-20.00:03:47.308>
    closer = 'eric.smith'
    components = ['C API']
    creation = <Date 2020-09-05.06:23:53.252>
    creator = 'ravi-misra'
    dependencies = []
    files = ['49447']
    hgrepos = []
    issue_num = 41724
    keywords = ['patch']
    message_count = 8.0
    messages = ['376425', '376435', '376446', '376447', '383408', '383410', '383411', '383412']
    nosy_count = 7.0
    nosy_names = ['eric.smith', 'berker.peksag', 'serhiy.storchaka', 'sblondon', 'miss-islington', 'Dennis Sweeney', 'ravi-misra']
    pr_nums = ['23855', '23862', '23863']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41724'
    versions = ['Python 3.8']

    @ravi-misra
    Copy link
    Mannequin Author

    @ravi-misra ravi-misra mannequin commented Sep 5, 2020

    I tested the timestamp column in SQLite with MAX/MIN queries. They return string values instead of datetime.datetime.

    @ravi-misra ravi-misra mannequin added 3.8 expert-C-API type-bug labels Sep 5, 2020
    @ericvsmith
    Copy link
    Member

    @ericvsmith ericvsmith commented Sep 5, 2020

    [Adjusted title so that it displays correctly when not logged in. The text within less-than and greater-than was being dropped, probably because some piece of code didn't want to display unknown tags.]

    @ericvsmith ericvsmith changed the title SQLite returns <str> instead of <datetime.datetime> with aggregate queries. SQLite returns "str" instead of "datetime.datetime" with aggregate queries. Sep 5, 2020
    @sweeneyde
    Copy link
    Member

    @sweeneyde sweeneyde commented Sep 5, 2020

    Here's a reproducer.

    @serhiy-storchaka
    Copy link
    Member

    @serhiy-storchaka serhiy-storchaka commented Sep 5, 2020

    PARSE_DECLTYPES does not work for generated fields. sqlite3_column_decltype() just returns NULL.

    PARSE_COLNAMES works only when the column name contains the column type in square brackets. For generated fields sqlite3_column_name() returns the expression used to evaluate it, e.g. "max(d)". It does not contain needed information.

    So we cannot do anything with this because SQLite just does not provide information needed to determine the type.

    It would be worth to document this limitation.

    @ericvsmith
    Copy link
    Member

    @ericvsmith ericvsmith commented Dec 19, 2020

    New changeset 09a36cd by sblondon in branch 'master':
    bpo-41724: Explain when the conversion is not possible with detect_types enabled (GH-23855)
    09a36cd

    @ericvsmith
    Copy link
    Member

    @ericvsmith ericvsmith commented Dec 20, 2020

    New changeset a34ab81 by Miss Islington (bot) in branch '3.9':
    bpo-41724: Explain when the conversion is not possible with detect_types enabled (GH-23855) (GH-23862)
    a34ab81

    @ericvsmith
    Copy link
    Member

    @ericvsmith ericvsmith commented Dec 20, 2020

    New changeset 24862b0 by Miss Islington (bot) in branch '3.8':
    bpo-41724: Explain when the conversion is not possible with detect_types enabled (GH-23855) (GH-23863)
    24862b0

    @ericvsmith
    Copy link
    Member

    @ericvsmith ericvsmith commented Dec 20, 2020

    Thanks for the PR!

    @ericvsmith ericvsmith closed this Dec 20, 2020
    @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.8 expert-C-API type-bug
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants