Closed MaxosHadj closed 1 month ago
Hey 👋
I tried to use raw SQL without success
You should provide the errors you're getting. Otherwise people can't help you.
sql
template tag has the lit
method for this use-case.
import { sql } from "kysely";
await db
.selectFrom("table")
.select([
"value_a",
"value_b",
sql.lit(null).as("c"),
sql.lit("myValue").as("d"),
])
.execute();
But be careful! to avoid SQL injection, you must validate strings passed to sql.lit
.
Trying to do the following:
SELECT value_a, value_b, null AS c FROM table
or
SELECT value_a, value_b, 'myValue' AS c FROM table
I tried to use raw SQL without success![image](https://github.com/kysely-org/kysely/assets/82805662/de8c27f3-c3ff-4487-b952-b6a895a0cb06)
Any idea?