@@ -2,9 +2,6 @@ import { describe, expect, it } from "vitest";
22import { compileTSQL , parseTSQLSelect , SyntaxError as TSQLSyntaxError } from "./index.js" ;
33import { column , type TableSchema } from "./query/schema.js" ;
44
5- // TSQL has no write statements at all, so a mutating query cannot parse.
6- // These tests pin that, so extending the grammar can't quietly add a write path.
7-
85const taskRunsSchema : TableSchema = {
96 name : "task_runs" ,
107 clickhouseName : "trigger_dev.task_runs_v2" ,
@@ -45,7 +42,6 @@ const mutating = [
4542 [ "SYSTEM" , "SYSTEM SHUTDOWN" ] ,
4643] ;
4744
48- // Shapes that defeat a keyword deny-list but not a grammar without write statements.
4945const evasions = [
5046 [ "lower case" , "delete from task_runs where id = 'run_1'" ] ,
5147 [ "mixed case" , "DeLeTe FROM task_runs WHERE id = 'run_1'" ] ,
@@ -68,15 +64,12 @@ describe("TSQL is read-only by construction", () => {
6864 expect ( ( ) => compileTSQL ( query , compileOptions as never ) ) . toThrow ( ) ;
6965 } ) ;
7066
71- // Positive control: the negatives above must fail because they mutate,
72- // not because the parser rejects everything.
67+ // Positive control: the negatives must fail because they mutate, not because everything does.
7368 it ( "still parses an ordinary SELECT" , ( ) => {
7469 const ast = parseTSQLSelect ( "SELECT id, status FROM task_runs WHERE status = 'FAILED'" ) ;
7570 expect ( ast . expression_type ) . toBe ( "select_query" ) ;
7671 } ) ;
7772
78- // TRUNCATE is a keyword in the lexer because it is a rounding function,
79- // not because a TRUNCATE statement exists.
8073 it ( "treats TRUNCATE as a function, not a statement" , ( ) => {
8174 const ast = parseTSQLSelect ( "SELECT truncate(1.9) FROM task_runs" ) ;
8275 expect ( ast . expression_type ) . toBe ( "select_query" ) ;
@@ -90,9 +83,6 @@ describe("a mutation cannot ride along behind a valid SELECT", () => {
9083 [ "two semicolons" , "SELECT id FROM task_runs;; TRUNCATE TABLE task_runs" ] ,
9184 ] ;
9285
93- // The parser is anchored to EOF, so a trailing statement is rejected rather
94- // than silently dropped. Silently dropping it would also be safe, but it
95- // would hide the smuggling attempt from the caller.
9686 it . each ( smuggled ) ( "rejects a mutation appended after a %s" , ( _label , query ) => {
9787 expect ( ( ) => parseTSQLSelect ( query ) ) . toThrow ( TSQLSyntaxError ) ;
9888 expect ( ( ) => compileTSQL ( query , compileOptions as never ) ) . toThrow ( ) ;
0 commit comments