Open codesfromshad opened 3 days ago
drizzle-orm
0.31.2
drizzle-kit
0.22.7
When I set .default(sql'FALSE').notNull() or .default(false).notNull(), manually entering a row does not result in FALSE by default.
.default(sql'FALSE').notNull()
.default(false).notNull()
FALSE
Check the snapshot:
The CHECK() constraint, using sql magic operator also doesn't work. I am aware the drizzle did not implement this yet.
CHECK()
sql
Please check the code snippet below for understanding what I am trying to achieve:
export const trackers = createTable( "tracker", { id: uuid("id").primaryKey(), createdAt: timestamp("created_at", { mode: "date", withTimezone: true, }).default(sql`CURRENT_TIMESTAMP`).notNull(), hashedId: varchar("hashed_id", { length: 255 }).notNull(), country: varchar("country", { length: 2 }).notNull(), isMalicious: boolean("is_malicious").default(sql`FALSE`).notNull(), canBypassProtection: boolean("can_bypass_protection").default(sql`FALSE`).notNull(), }, (tracker) => ({ hashedIdIdx: index("tacker_hashedId_idx").on(tracker.hashedId), canBypassProtectionCstr: sql`CHECK (can_bypass_protection = FALSE OR (can_bypass_protection = TRUE AND is_malicious = TRUE))`, // <-- DOESN'T WORK }) );
It should be FALSE by default.
No response
What version of
drizzle-orm
are you using?0.31.2
What version of
drizzle-kit
are you using?0.22.7
Describe the Bug
When I set
.default(sql'FALSE').notNull()
or.default(false).notNull()
, manually entering a row does not result inFALSE
by default.Check the snapshot:![image](https://github.com/drizzle-team/drizzle-orm/assets/92628452/11335229-7882-4797-a6fb-5a55363ffa06)
The
CHECK()
constraint, usingsql
magic operator also doesn't work. I am aware the drizzle did not implement this yet.Please check the code snippet below for understanding what I am trying to achieve:
Expected behavior
It should be
FALSE
by default.Environment & setup
No response