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

Custom Queries - escaping strings #183

Closed
psychemedia opened this issue Jan 25, 2018 · 2 comments
Closed

Custom Queries - escaping strings #183

psychemedia opened this issue Jan 25, 2018 · 2 comments

Comments

@psychemedia
Copy link
Contributor

psychemedia commented Jan 25, 2018

If a SQLite table column name contains spaces, they are usually referred to in double quotes:

SELECT * FROM mytable WHERE "gappy column name"="my value";

In the JSON metadata file, this is passed by escaping the double quotes:

"queries": {"my query": "SELECT * FROM mytable WHERE \"gappy column name\"=\"my value\";"}

When specifying a custom query in metadata.json using double quotes, these are then rendered in the datasette query box using single quotes:

SELECT * FROM mytable WHERE 'gappy column name'='my value';

which does not work.

Alternatively, a valid custom query can be passed using backticks (`) to quote the column name and single (unescaped) quotes for the matched value:

"queries": {"my query": "SELECT * FROM mytable WHERE `gappy column name`='my value';"}

@simonw
Copy link
Owner

simonw commented Apr 3, 2018

I'm having trouble replicating this bug. In particular, I don't understand what you mean by "these are then rendered in the datasette query box using single quotes" - since canned queries aren't displayed in a textarea. Do you have an example database / metadata.json I can use to investigate this further?

@simonw
Copy link
Owner

simonw commented Jun 24, 2019

Closing as couldn't replicate

@simonw simonw closed this as completed Jun 24, 2019
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

2 participants