Can a CHECK constraint take sql builders (eq, lt, isNull)?

The types say these output SQL | undefined, while the check takes in SQL, so there is a type mismatch. The docs use
import { sql } from "drizzle-orm";
import { check, int, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const users = sqliteTable(
"users",
{
id: int().primaryKey(),
username: text().notNull(),
age: int(),
},
(table) => [
check("age_check1", sql`${table.age} > 21`)
]
);
import { sql } from "drizzle-orm";
import { check, int, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const users = sqliteTable(
"users",
{
id: int().primaryKey(),
username: text().notNull(),
age: int(),
},
(table) => [
check("age_check1", sql`${table.age} > 21`)
]
);
Is this intended that you must use the sql syntax?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?