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

investigate sqlite3 vs pysqlite3-binary difference #98

Closed
cldellow opened this issue Feb 27, 2023 · 4 comments
Closed

investigate sqlite3 vs pysqlite3-binary difference #98

cldellow opened this issue Feb 27, 2023 · 4 comments

Comments

@cldellow
Copy link
Owner

import sqlite3
import pysqlite3

sql = '''WITH xs AS (SELECT json(1) x) SELECT json_group_array(x) FROM xs'''

def go(module):
    c = module.connect(':memory:')
    rv = c.execute(sql).fetchall()
    print('{}: {}'.format(module.sqlite_version, rv))

go(sqlite3)
go(pysqlite3)

Gives this output:

3.31.1: [('[1]',)]
3.40.0: [('["1"]',)]

This was the root cause of #97

@cldellow
Copy link
Owner Author

I first repro this with 3.39.0 (pysqlite3-binary 0.4.7post6)

@cldellow
Copy link
Owner Author

Hm, I think the new behaviour is by design :(

See https://sqlite.org/forum/forumpost/c96206d45c6122e1c81fc18d220fd3d5e183aac9f08294fb242671398090a44d

@cldellow
Copy link
Owner Author

@cldellow
Copy link
Owner Author

The gist seems to be: the JSON functions can introduce a new JSON type (as opposed to the standard REAL, TEXT, BLOB, etc).

This type was previously allowed to escape subqueries, which introduced the opportunity for inconsistency.

It no longer is permitted to do that, and is serialized as a string when it escapes.

Can we get the same behaviour by explicitly casting to text?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant