vrischmann / zig-sqlite

zig-sqlite is a small wrapper around sqlite's C API, making it easier to use with Zig.
MIT License
367 stars 49 forks source link

Characters inside strings incorrectly identified as bind markers #65

Closed lonjil closed 2 years ago

lonjil commented 2 years ago

In at least some circumstances, $, ?, etc, will be detected as bind markers for the statement, even when they are used inside of strings.

For example:

const create =
    \\CREATE TABLE IF NOT EXISTS image(
    \\  iid INTEGER PRIMARY KEY,
    \\  eid INTEGER UNIQUE,
    \\  metadata TEXT,
    \\  full_url TEXT GENERATED ALWAYS AS
    \\    (json_extract(metadata, '$.image.representations.full')) VIRTUAL,
    \\  thumb_url TEXT GENERATED ALWAYS AS
    \\    (json_extract(metadata, '$.image.representations.thumb')) VIRTUAL,
    \\  extension TEXT GENERATED ALWAYS AS
    \\    (json_extract(metadata, '$.image.format')) VIRTUAL,
    \\  hash_meta TEXT,
    \\  image_id INTEGER,
    \\  thumb_id INTEGER
    \\);
;

Here, the dollar signs inside the PATH argument to json_extract are detected as being bind markers, resulting in a compile time error due to a mismatch of the number of bind markers vs the number of value fields.

vrischmann commented 2 years ago

Hey, thanks for reporting this. I'll try to look into this in the near future.