digital-fabric / extralite

Ruby on SQLite
http://www.rubydoc.info/gems/extralite
MIT License
247 stars 7 forks source link

`execute` didn't work when SQL ends with a comment #72

Closed gschlager closed 3 months ago

gschlager commented 3 months ago

Calling execute with SQL like the following didn't work:

INSERT INTO t (x, y, z) VALUES (7, 7, 7);
INSERT INTO t (x, y, z) VALUES (8, 8, 8);
-- this is a comment at the end

Executing that SQL results in a Extralite::Error: not an error error because prepare_multi_stmt_impl can set stmt to NULL when SQL ends with a comment. The documentation for sqlite3_prepare_v2 states:

If the input text contains no SQL (if the input is an empty string or a comment) then *ppStmt is set to NULL.

noteflakes commented 3 months ago

Great fix, thanks @gschlager !