FG
๐Ÿ’ป Software๐Ÿ—„๏ธ Databases

[BUG]: Can't parse float(8,2) from database (precision and scale and/or unsigned breaks float types)

Fresh3 days ago
Mar 14, 20260 views
Confidence Score55%
55%

Problem

What version of `drizzle-orm` are you using? 0.28.5 What version of `drizzle-kit` are you using? 0.19.13 Describe the Bug Then the schema file fails to generate the column definition/type for any column defined as `float(x,y)` When I call `drizzle-kit introspect:mysql`, I get this in my output: `uknown float(8,2)` This is what the generated schema.ts looks like [code block] Here's my actual MySQL schema: [code block] Expected behavior I expect the output to looks something like this: [code block] Environment & setup Node v18.12.1 MacOS Ventura 13.4 MySQL 8.0.33

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Fix float(8,2) Parsing Issue in Drizzle ORM

Medium Risk

The current versions of `drizzle-orm` (0.28.5) and `drizzle-kit` (0.19.13) do not properly handle MySQL float types defined with precision and scale (e.g., float(8,2)). This results in the introspection tool failing to recognize the type, leading to the 'unknown float(8,2)' error.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update Drizzle ORM and Drizzle Kit

    Check for the latest versions of `drizzle-orm` and `drizzle-kit` that may have addressed this issue. Update your package.json and reinstall the packages.

    bash
    npm install drizzle-orm@latest drizzle-kit@latest
  2. 2

    Modify MySQL Schema

    If updating does not resolve the issue, consider altering the MySQL schema to use standard float types without precision and scale, or switch to using decimal types which are better supported.

    sql
    ALTER TABLE your_table MODIFY your_column DECIMAL(8,2);
  3. 3

    Create Custom Type Mapping

    If you need to keep the float type with precision and scale, create a custom type mapping in your Drizzle ORM configuration to handle float(8,2) appropriately.

    typescript
    drizzle.defineType('float8_2', { type: 'float', precision: 8, scale: 2 });
  4. 4

    Run Introspection Again

    After making the changes, run the introspection command again to verify that the float types are now correctly recognized.

    bash
    npx drizzle-kit introspect:mysql

Validation

Confirm that the introspection command no longer outputs 'unknown float(8,2)' and that the schema.ts file correctly reflects the float types as expected.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbugdrizzle/kitdb/mysqlpriority