drizzle-team / drizzle-team/drizzle-orm
[BUG]: SQLite incorrectly scaffolds boolean column with drizzle-kit pull
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
1.0.0-rc.4
### What version of `drizzle-kit` are you using?
1.0.0-rc.4
### Other packages
_No response_
### Describe the Bug
I'm scaffolding a drizzle schema from SQLite ddl that looks like this in part
pending BOOLEAN NOT NULL DEFAULT true,
error BOOLEAN NOT NULL DEFAULT false,
the generated schema fields look like this
pending: numeric().default(true).notNull(),
error: numeric().default(false).notNull(),
which is an error of
Argument of type 'boolean' is not assignable to parameter of type 'string | SQL'.ts(2345)
Also, if the default value in the DDL is TRUE and FALSE (all caps) then the generated schema.ts file references literally TRUE and FALSE (which is of course an undeclared variable)
Here's the entire DDL
export const initialWorkoutTemplateDDL = `
CREATE TABLE IF NOT EXISTS session (
id INTEGER PRIMARY KEY,
created_at TEXT NOT NULL,
name TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS session_prompt (
id INTEGER PRIMARY KEY,
session_id INTEGER NOT NULL,
created_at TEXT NOT NULL,
prompt TEXT NOT NULL,
saved_id INTEGER NULL,
workout_templates TEXT NOT NULL,
pending BOOLEAN NOT NULL DEFAULT true,
error BOOLEAN NOT NULL DEFAULT false,
FOREIGN KEY (session_id)
REFERENCES session(id)
ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS session_prompt_result (
id INTEGER PRIMARY KEY,
session_prompt_id INTEGER NOT NULL,
result TEXT NOT NULL,
FOREIGN KEY (session_prompt_id)
REFERENCES session_prompt(id)
ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_session_prompt_session_id
ON session_prompt(session_id);
CREATE INDEX IF NOT EXISTS idx_session_prompt_result_session_prompt_id
ON session_prompt_result(session_prompt_id);
`;
Contributor guide
Research direction
Start by running drizzle-kit pull against the supplied SQLite DDL and inspect the generated schema.ts for the pending and error columns. Trace how BOOLEAN columns and true/false defaults are represented, then verify that the generated TypeScript accepts boolean defaults and does not emit undeclared TRUE or FALSE identifiers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sqlite, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100