constdynamicStatements=[]dynamicStatements.push(SQL` WHERE table_1.column_1 = ${x}`)dynamicStatements.push(SQL` AND table_1.column_2 = ${y}`)awaitQUERY/* sql */` SELECT * FROM table_1${dynamicStatements} `Currently this throws an error as it tries to parse the dynamicsStatements array as just a single statement.
My current workaround is as follows:
exportfunctionjoinStatements(statements: any[],{ join =' ', prefix =' '}: {join: string,prefix: string}={join: ' ',prefix: ' '}){consttagSymbol=Object.getOwnPropertySymbols(statements[0])[0]constvalues: any[]=[]consttextParts: string[]=[]for(conststatementofstatements){constres=statement()textParts.push(res.text)values.push(...res.values)}constres=Object.assign(()=>({text: prefix+textParts.join(join),
values,}),{[tagSymbol]: true,},)returnres}It's especially hacky as the tag Symbol isn't exported, so I have to fetch it like so.
If there is functionality to support this and I missed it, please let me know.
Currently this throws an error as it tries to parse the dynamicsStatements array as just a single statement.
My current workaround is as follows:
It's especially hacky as the tag Symbol isn't exported, so I have to fetch it like so.
If there is functionality to support this and I missed it, please let me know.