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

@ -224,7 +224,7 @@
"sql.insert<${1:Row}>(${2:row})",
" .onConflict { ${3:it.id} }",
" .doUpdate { ${4:excluded} ->",
" set(${1:Row}.${5:value}, ${4:excluded}.${5:value})",
" ${1:Row}.${5:value} = ${4:excluded}.${5:value}",
" }",
" .build()"
],
@ -233,9 +233,9 @@
"SQL Update Returning": {
"prefix": "sqlupdatereturning",
"body": [
"val ${1:updated}: *${2:Row} = sql.update<${2:Row}>()",
"val ${1:updated}: ${2:Row} = sql.update<${2:Row}>()",
" .set { ${3:row} ->",
" set(${3:row}.${4:value}, ${5:newValue})",
" ${3:row}.${4:value} = ${5:newValue}",
" }",
" .where { ${6:it.id == id} }",
" .returning { it }",
@ -243,6 +243,22 @@
],
"description": "Update and return a typed SQL row"
},
"SQL Bulk Insert": {
"prefix": "sqlbulk",
"body": ["val ${1:query} = sql.insertAll<${2:Row}>(${3:rows}).build()"],
"description": "Build a typed bulk insert"
},
"SQL Join And Aggregate": {
"prefix": "sqljoin",
"body": [
"val ${1:query} = sql.from<${2:LeftRow}>()",
" .alias(\"${3:left}\")",
" .leftJoin<${4:RightRow}>(\"${5:right}\") { ${3:left}, ${5:right} -> ${3:left}.${6:id} == ${5:right}.${7:leftId} }",
" .groupBy { ${3:left}, ${5:right} -> ${3:left}.${6:id} }",
" .build()"
],
"description": "Build a typed joined and grouped query"
},
"If": {
"prefix": "if",
"body": [