drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.54k stars 643 forks source link

[BUG]: drizzle-kit introspect: SMALLINT import missing and incorrect DECIMAL UNSIGNED handling #2950

Closed ygpark80 closed 1 week ago

ygpark80 commented 2 months ago

What version of drizzle-orm are you using?

0.33.0

What version of drizzle-kit are you using?

0.24.2

Describe the Bug

  1. When a MySQL table has a SMALLINT type, running drizzle-kit introspect doesn't import the smallint type in the import statement.
  2. Additionally, for the DECIMAL UNSIGNED type, it generates the code incorrectly. The incorrect output looks like this:
    duration: decimal("duration", { precision: 10, scale: 5 }) unsigne }),

Expected behavior

  1. The import line should include smallint, like this:
    import { mysqlTable, mysqlSchema, AnyMySqlColumn, primaryKey, int, decimal, smallint } from "drizzle-orm/mysql-core"
  2. Since the UNSIGNED attribute is deprecated for DECIMAL, it should ignore the UNSIGNED attribute and generate something like:
    duration: decimal("duration", { precision: 10, scale: 5 })

Environment & setup

A reproduction of this issue can be found at https://github.com/ygpark80/drizzle-kit-introspect

You can use docker compose up to set up the environment, and then run yarn pull to generate the error.

ygpark80 commented 1 month ago

Is anyone from the Drizzle team going to respond at all? I even have PRs for the problems outlined here.

AndriiSherman commented 1 week ago

Was fixed in drizzle-kit@0.28.0