Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] When using double type columns, import is not inserted #403

Open
Karibash opened this issue May 13, 2024 · 0 comments
Open

[BUG] When using double type columns, import is not inserted #403

Karibash opened this issue May 13, 2024 · 0 comments

Comments

@Karibash
Copy link

Karibash commented May 13, 2024

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.0

What type of database are you using?

MySQL

Describe the Bug

When generating a schema with the introspect command for a database that has columns with double type columns, import is not inserted.

This is because double is not taken into account in the logic that determines whether or not to insert an import.

const columnImports = Object.values(it.columns).map((col) => {
  let patched = importsPatch[col.type] ?? col.type;
  patched = patched.startsWith("varchar(") ? "varchar" : patched;
  patched = patched.startsWith("char(") ? "char" : patched;
  patched = patched.startsWith("binary(") ? "binary" : patched;
  patched = patched.startsWith("decimal(") ? "decimal" : patched;
  patched = patched.startsWith("smallint(") ? "smallint" : patched;
  patched = patched.startsWith("enum(") ? "mysqlEnum" : patched;
  patched = patched.startsWith("datetime(") ? "datetime" : patched;
  patched = patched.startsWith("varbinary(") ? "varbinary" : patched;
  patched = patched.startsWith("int(") ? "int" : patched;
  return patched;
})

Expected behavior

If a column uses type double, import is correctly inserted.

Patch

The following patch can be applied as a workaround until this issue is resolved.

diff --git a/bin.cjs b/bin.cjs
index fef2511d2e2d69c877fc925c281d88aa828f150f..12c700646dd7e88184b6a38f604d26f3fa32953a 100755
--- a/bin.cjs
+++ b/bin.cjs
@@ -107701,6 +107701,7 @@ var init_introspect_mysql = __esm({
             patched = patched.startsWith("datetime(") ? "datetime" : patched;
             patched = patched.startsWith("varbinary(") ? "varbinary" : patched;
             patched = patched.startsWith("int(") ? "int" : patched;
+            patched = patched.startsWith("double(") ? "double" : patched;
             return patched;
           }).filter((type) => {
             return mysqlImportsList.has(type);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant