datasette icon indicating copy to clipboard operation
datasette copied to clipboard

datasette breaks on square brackets in table name

Open slavos1 opened this issue 4 months ago • 0 comments

First off, thanks for datasette. 🙏🏻

Checking Evolution's data, I've hit a snag with tables with names like [Gmail]/Inbox.

A minimal reproduction:

$ sqlite3 /tmp/slashes
SQLite version 3.45.1 2024-01-30 16:01:20
Enter ".help" for usage hints.
sqlite> create table "[foo]/bar" (a text);
Ctrl-D

$ datasette /tmp/slashes
Usage: datasette serve [OPTIONS] [FILES]...
Try 'datasette serve --help' for help.

Error: Connection to /tmp/slashes failed check: near "/": syntax error

$ datasette --version
datasette, version 0.64.8

Testing further, having only [...] fails with:

$ sqlite3 /tmp/slashes
SQLite version 3.45.1 2024-01-30 16:01:20
Enter ".help" for usage hints.
sqlite> create table "[foo]" (a text);

$ datasette /tmp/slashes
Usage: datasette serve [OPTIONS] [FILES]...
Try 'datasette serve --help' for help.

Error: Connection to /tmp/slashes failed check: unrecognized token: "]"

In summary:

Table name Works with datasette?
[foo]/bar no (failed check: near "/": syntax error)
[foo] no (failed check: unrecognized token: "]")
[foo yes
foo] no (failed check: unrecognized token: "]")
foo/bar yes

sqlite3 cli itself does not have problems with any names mentioned above.

slavos1 avatar Sep 23 '24 23:09 slavos1