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

JSON filter fails if column contains spaces #1239

Closed
simonw opened this issue Feb 23, 2021 · 1 comment
Closed

JSON filter fails if column contains spaces #1239

simonw opened this issue Feb 23, 2021 · 1 comment
Labels

Comments

@simonw
Copy link
Owner

simonw commented Feb 23, 2021

Got this exception:

ERROR: conn=<sqlite3.Connection object at 0x10ea68e40>, sql = 'select Address, Affiliation, County, [Has Report], [Latest report notes], [Latest report yes], Latitude, [Location Type], Longitude, Name, id, [Appointment scheduling instructions], [Availability Info], [Latest report] from locations where rowid in (\n select locations.rowid from locations, json_each(locations.Availability Info) j\n where j.value = :p0\n ) and "Latest report yes" = :p1 order by id limit 101', params = {'p0': 'Yes: appointment required', 'p1': '1'}: near "Info": syntax error

@simonw simonw added the bug label Feb 23, 2021
@simonw
Copy link
Owner Author

simonw commented Feb 23, 2021

Bug is here:

TemplatedFilter(
"arraycontains",
"array contains",
"""rowid in (
select {t}.rowid from {t}, json_each({t}.{c}) j
where j.value = :{p}
)""",
'{c} contains "{v}"',
),
TemplatedFilter(
"arraynotcontains",
"array does not contain",
"""rowid not in (
select {t}.rowid from {t}, json_each({t}.{c}) j
where j.value = :{p}
)""",
'{c} does not contain "{v}"',

Those json_each lines should be:

select {t}.rowid from {t}, json_each([{t}].[{c}]) j

@simonw simonw closed this as completed in 726f781 Feb 23, 2021
simonw added a commit to simonw/vaccinate-ca-datasette that referenced this issue Feb 23, 2021
simonw added a commit that referenced this issue Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant