Skip to content

Support parsing doubly quoted strings as identifiers#296

Open
garnacho wants to merge 1 commit intoasg017:mainfrom
garnacho:quoted-identifiers
Open

Support parsing doubly quoted strings as identifiers#296
garnacho wants to merge 1 commit intoasg017:mainfrom
garnacho:quoted-identifiers

Conversation

@garnacho
Copy link
Copy Markdown

@garnacho garnacho commented May 8, 2026

Per https://www.sqlite.org/lang_keywords.html, SQLite supports identifiers expressed as strings surrounded between double quotes:

$ sqlite3
SQLite version 3.52.0 2026-03-06 16:01:44
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table a("oh,boy!" TEXT);
sqlite> pragma table_info(a);
╭─────┬─────────┬──────┬─────────┬────────────┬────╮
│ cid │  name   │ type │ notnull │ dflt_value │ pk │
╞═════╪═════════╪══════╪═════════╪════════════╪════╡
│   0 │ oh,boy! │ TEXT │       0 │ NULL       │  0 │
╰─────┴─────────┴──────┴─────────┴────────────┴────╯

When identifiers are parsed as such, no escaping applies, i.e. backslashes don't affect the next character:

sqlite> create table b("oh\tno\" TEXT);
sqlite> pragma table_info(b);
╭─────┬─────────┬──────┬─────────┬────────────┬────╮
│ cid │  name   │ type │ notnull │ dflt_value │ pk │
╞═════╪═════════╪══════╪═════════╪════════════╪════╡
│   0 │ oh\tno\ │ TEXT │       0 │ NULL       │  0 │
╰─────┴─────────┴──────┴─────────┴────────────┴────╯

Make sqlite-vec internal scanner handle these identifiers, so that the column names in a vec0 virtual table may have the same (reduced) limitations as any other SQLite table.

Note: SQLite also implements similar support for single quoted strings to be handled as identifiers. This is done for compatibility with other SQL implementations rather than standard conformance, so it's perhaps a bit more dubious to support.

@garnacho garnacho force-pushed the quoted-identifiers branch from 766a498 to f381ea1 Compare May 11, 2026 11:02
Per https://www.sqlite.org/lang_keywords.html, SQLite supports
identifiers expressed as strings surrounded between double quotes:

    $ sqlite3
    SQLite version 3.52.0 2026-03-06 16:01:44
    Enter ".help" for usage hints.
    Connected to a transient in-memory database.
    Use ".open FILENAME" to reopen on a persistent database.
    sqlite> create table a("oh,boy!" TEXT);
    sqlite> pragma table_info(a);
    ╭─────┬─────────┬──────┬─────────┬────────────┬────╮
    │ cid │  name   │ type │ notnull │ dflt_value │ pk │
    ╞═════╪═════════╪══════╪═════════╪════════════╪════╡
    │   0 │ oh,boy! │ TEXT │       0 │ NULL       │  0 │
    ╰─────┴─────────┴──────┴─────────┴────────────┴────╯

When identifiers are parsed as such, no escaping applies, i.e.
backslashes don't affect the next character:

    sqlite> create table b("oh\tno\" TEXT);
    sqlite> pragma table_info(b);
    ╭─────┬─────────┬──────┬─────────┬────────────┬────╮
    │ cid │  name   │ type │ notnull │ dflt_value │ pk │
    ╞═════╪═════════╪══════╪═════════╪════════════╪════╡
    │   0 │ oh\tno\ │ TEXT │       0 │ NULL       │  0 │
    ╰─────┴─────────┴──────┴─────────┴────────────┴────╯

Make sqlite-vec internal scanner handle these identifiers, so
that the column names in a vec0 virtual table may have the same
(reduced) limitations as any other SQLite table.

Note: SQLite also implements similar support for single quoted
strings to be handled as identifiers. This is done for compatibility
with other SQL implementations rather than standard conformance,
so it's perhaps a bit more dubious to support.
@garnacho garnacho force-pushed the quoted-identifiers branch from f381ea1 to b9df189 Compare May 11, 2026 11:06
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

Successfully merging this pull request may close these issues.

1 participant