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.68k stars 651 forks source link

[BUG]: sqlite column definition typescript argument mismatch #3571

Open luroc opened 1 week ago

luroc commented 1 week ago

Report hasn't been filed before.

What version of drizzle-orm are you using?

0.33.0

What version of drizzle-kit are you using?

0.22.8

Other packages

-

Describe the Bug

While defining sqlite columns using your examples in the documentation

import { integer, sqliteTable } from "drizzle-orm/sqlite-core";

const contentFrame = sqliteTable('contentFrame', {
    id: integer({ mode: 'number' }).primaryKey({ autoIncrement: true })
});

typescript errors with typescript: Argument of type '{ mode: string; }' is not assignable to parameter of type 'string'. [2345]. Likewise npx drizzle-kit push errors with

npx drizzle-kit push                        
drizzle-kit: v0.22.8
drizzle-orm: v0.33.0                                     

_ZodError: [
  {                                                      
    "code": "invalid_type",                                                                                        
    "expected": "string",
    "received": "object",
    "path": [                                
      "tables",
      "table",                                                                                             
      "columns",                                                                                                   
      "[object Object]",    
      "name"                                                                                                       
    ],                                                                                                             
    "message": "Expected string, received object"                                                                  
  }                                                                                                                
]                                                                                                                      at get error [as error] (/XXX/node_modules/drizzle-kit/bin.cjs:5183:
28)                                                                                                                
    at _ZodObject.parse (/XXX/node_modules/drizzle-kit/bin.cjs:5263:22)     at prepareSQLitePush (/XXX/node_modules/drizzle-kit/bin.cjs:30542:41
)                                                                                                                      at async sqlitePush (/XXX/node_modules/drizzle-kit/bin.cjs:122578:26
)                                                                                                                      at async _Command.<anonymous> (/XXX/node_modules/drizzle-kit/bin.cjs
:129691:7) {                                                                                                       
  issues: [                                                                                                        
    {                       
      code: 'invalid_type',                              
      expected: 'string',   
      received: 'object',                                
      path: [Array],                                     
      message: 'Expected string, received object'        
    }                                                    
  ],                                                     
  addIssue: [Function (anonymous)],                     
  addIssues: [Function (anonymous)],                     
  errors: [                 
    {                                                    
      code: 'invalid_type',                                                                                        
      expected: 'string',                                
      received: 'object',
      path: [Array],                                     
      message: 'Expected string, received object'        
    }                       
  ]                                                                                                                
}   

better-sqlite3, monorepo, typescript v5.6.3, nodejs, tsconfig.json:

{
    "extends": "./.svelte-kit/tsconfig.json",
    "compilerOptions": {
        "allowJs": true,
        "checkJs": true,
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "resolveJsonModule": true,
        "skipLibCheck": true,
        "sourceMap": true,
        "strict": true,
        "moduleResolution": "bundler"
    }
    // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
    // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
    //
    // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
    // from the referenced tsconfig.json - TypeScript does not merge them in
}