tursodatabase / libsql-shell-go

7 stars 7 forks source link

Parse semicolons correctly when creating triggers #124

Closed douglasmdev closed 1 year ago

douglasmdev commented 1 year ago

Glauber has raised the following issue:

Given the following table:

CREATE TABLE users (
        id text PRIMARY KEY DEFAULT (uuid4()) NOT NULL,
        updated_at integer DEFAULT CURRENT_TIMESTAMP NOT NULL
)

The following trigger statement works on sqlite3, but not on sqld:

CREATE TRIGGER update_updated_at AFTER UPDATE ON users FOR EACH ROW BEGIN UPDATE users SET updated_at = 0 WHERE id = NEW.id; end;

This is hapening because we treat semi-colons as the end of a statement, which is not true for CREATE TRIGGER statements.

glommer commented 1 year ago

just FYI, someone hit this again today. the workaround is to not use the shell for that for the time being, and use an SDK instead