durcno@1.0.0-alpha.22
Minor Changes
-
e99f947 - Thanks to @almahdi404 !
feat(sql): add lazy evaluation and support for prepared arguments in sql template
Refactored the
Sqlclass to lazily evaluate template string fragments and parameters when.toSQL(),.string, or.toQuery()is called.Added support for interpolating prepared query arguments (
Arg) intosqltagged template expressions, allowingArgplaceholders to be used inside raw SQL fragments for prepared queries. Attempting to call.toSQL()directly on aSqltemplate containing anArgoutside of a query context will throw a descriptive error.const selectPre = prepare({ age: Arg.number() }, (args) =>db.prepare().from(Users).select().where(sql`age = ${args.age}`));
Patch Changes
-
3bd7a2d - Thanks to @almahdi404 !
fix(qb): fix SqlFn TPrepare generic type constraint in query builders
Refine the
TPreparetype argument passed toSqlFninGroupByExpression,OrderExpression,SelectBuilder, andSelectQuerytoTPrepare extends true ? boolean : false.This resolves TypeScript inference and constraint mismatches when using SQL functions in select,
groupBy, andorderByclauses.