[BUG]: drizzle-zod when using coerce: true maps `float` as `int` and vice versa
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- databases
Research direction
Start in drizzle-zod/src/column.ts around line 244 and reproduce the reported createSchemaFactory({ coerce: true }) case with a PostgreSQL doublePrecision column. Check the generated schema's number handling; done when a float value such as 5.5 parses correctly while integer columns still enforce integer values.
Written by the indexing model from the issue text.
Description
Report hasn't been filed before.
- I have verified that the bug I'm about to report hasn't been filed before.
Other packages
drizzle-zod 0.8.2
Describe the Bug
const test = pgTable("test", {
float: doublePrecision(),
});
const { createSelectSchema } = createSchemaFactory({
coerce: true,
});
const schema = createSelectSchema(test);
schema.parse({ float: 5.5 }); // error thrown here
In this case float field in schema will be integer because of wrong ternary operator here:
https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-zod/src/column.ts#L244
integer ? z.coerce.number() : z.coerce.number().int()
Number field is returned when column type is int and vice versa(int returned when actual type is float)
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from drizzle-team/drizzle-orm
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
drizzle-team/drizzle-orm#6287 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
drizzle-team/drizzle-orm#6229 ·
-
bug drizzle/kit
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
drizzle-team/drizzle-orm#6214 ·
-
bug bug/fixed-in-beta drizzle/kit
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
drizzle-team/drizzle-orm#6192 · 3 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
drizzle-team/drizzle-orm#6162 · 3 comments · 1 reaction ·
All issues in drizzle-team/drizzle-orm
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100