Expand typed SQL DSL

This commit is contained in:
pavel 2026-08-28 00:02:32 +02:00
commit 314c8fb207
17 changed files with 1082 additions and 498 deletions

View file

@ -47,10 +47,10 @@ const expectedTokens = [
"throw", "enum", "match", "package", "import", "jsonNaming", "embed", "table", "column", "id",
"generated", "Int", "Long", "String", "Boolean", "Unit", "Double", "Float", "Any",
"ByteSlice", "Error", "Result", "List", "MutableList", "Map", "MutableMap", "Channel", "GotlinSQLQuery",
"GotlinSQLIterator", "from", "where", "orderBy", "orderByDescending", "limit",
"GotlinSQLIterator", "from", "alias", "join", "leftJoin", "rightJoin", "where", "groupBy", "having", "orderBy", "orderByDescending", "limit", "offset",
"runBlocking", "coroutineScope", "launch", "async", "await", "delay", "withTimeout", "isActive",
"forUpdate", "skipLocked", "insert", "update", "delete", "onConflict", "doNothing",
"doUpdate", "returning", "build", "fetch", "single", "iterator", "set", "now", "mapTo"
"forUpdate", "skipLocked", "insert", "insertAll", "update", "delete", "onConflict", "doNothing",
"doUpdate", "returning", "build", "fetch", "single", "iterator", "count", "sum", "avg", "min", "max", "now", "mapTo"
];
for (const token of expectedTokens) {
assert(grammarSource.includes(token), `grammar is missing ${token}`);
@ -63,9 +63,9 @@ for (const annotation of ["jsonNaming", "embed", "table", "column", "id", "gener
const sqlSource = JSON.stringify(grammar.repository.sql);
for (const method of [
"from", "where", "select", "orderBy", "orderByDescending", "limit", "forUpdate",
"skipLocked", "insert", "update", "delete", "onConflict", "doNothing", "doUpdate",
"returning", "build", "fetch", "single", "iterator", "set", "now"
"from", "alias", "join", "leftJoin", "rightJoin", "where", "select", "groupBy", "having", "orderBy", "orderByDescending", "limit", "offset", "forUpdate",
"skipLocked", "insert", "insertAll", "update", "delete", "onConflict", "doNothing", "doUpdate",
"returning", "build", "fetch", "single", "iterator", "count", "sum", "avg", "min", "max", "now"
]) {
assert(sqlSource.includes(method), `SQL grammar is missing ${method}`);
}
@ -83,7 +83,7 @@ for (const declaration of [
const prefixes = new Set(Object.values(snippets).map((snippet) => snippet.prefix));
for (const prefix of [
"dataclass", "exprfun", "withcontext", "genericfun", "genericclass", "tablerow", "embed", "coroutinescope", "launch", "async", "enum", "match", "matchvalue", "mapto", "safe", "nonnull", "resultfun", "resultmatch", "defer", "foreach", "sqlfetch",
"sqlsingle", "sqliterator", "sqlinsertnothing", "sqlinsertupdate", "sqlupdatereturning"
"sqlsingle", "sqliterator", "sqlinsertnothing", "sqlinsertupdate", "sqlupdatereturning", "sqlbulk", "sqljoin"
]) {
assert(prefixes.has(prefix), `snippets are missing prefix ${prefix}`);
}