tursodatabase / libsql-shell-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse semicolons correctly when creating triggers

douglasmdev opened this issue · comments

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.

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