Files
turso/tests
Jussi Saurio a0a1bd6637 Triggers: fix issues with ALTER TABLE
- Disallow DROP COLUMN on columns referenced in triggers
- Propagate RENAME COLUMN to trigger SQL definitions

DROP COLUMN is not allowed when the column is mentioned in a trigger
on the table the column is dropped from, eg:

```
turso> CREATE TABLE t(x,y);
turso> CREATE TRIGGER foo BEFORE INSERT ON t BEGIN INSERT INTO t VALUES (NEW.x); END;
turso> ALTER TABLE t DROP COLUMN x;
  × Parse error: cannot drop column "x": it is referenced in trigger foo
```

However, it is allowed if the trigger is on another table:

```
turso> CREATE TABLE t(x,y);
turso> CREATE TABLE u(x,y);
turso> CREATE TRIGGER bar BEFORE INSERT ON t BEGIN INSERT INTO u(y) VALUES (NEW.x); END;
turso> ALTER TABLE u DROP COLUMN y;
turso> INSERT INTO t VALUES (1,1);
  × Parse error: table u has no column named y
```

Nearly all of the code here is vibecoded. I first asked Cursor Composer to create
an initial implementation. Then, I asked it to try to discover edge cases using the
`turso` and `sqlite3` CLIs, and write tests+fixes for the edge cases found.

The code is a bit slop, but this isn't a particularly performance-critical use case
and it should solve most of the issues with RENAME and DROP COLUMN.
2025-11-19 14:29:33 +02:00
..

Integration and regression test suite.


# run all tests
cargo test 

# run individual test
cargo test test_sequential_write -- --nocapture