WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.23k stars 390 forks source link

value.getTime is not a function #1121

Closed quantuminformation closed 6 months ago

quantuminformation commented 6 months ago

Thanks for this cool project

this code in this basic repo

https://github.com/quantuminformation/drizzle-sqlite-recurring-events

when running pnpm run db:seed gives error


//https://github.com/quantuminformation/drizzle-sqlite-recurring-events/blob/main/db/seed.ts
const events = await db
    .insert(schema.event)
    .values([
        {
            name: 'Event 1',
            startTime: new Date(2025, 1, 1, 19, 0, 0).getTime(),
            endTime: new Date(2025, 1, 1, 20, 0, 0).getTime(),
        },
    ])
    .returning()
TypeError: value.getTime is not a function
    at SQLiteTimestamp.mapToDriverValue (/Users/nikos/WebstormProjects/drizzle-sqlite-recurring-events/node_modules/.pnpm/drizzle-orm@0.29.1_better-sqlite3@9.2.2/node_modules/src/sqlite-core/columns/integer.ts:150:22)

you can see that getTime works when debugging in vscode so I don't know where this error originates

image

quantuminformation commented 6 months ago

i got same error with bun so closing

value.getTime is not a function. (In 'value.getTime()', 'value.getTime' is undefined) at mapToDriverValue (/Users/nikos/WebstormProjects/drizzle-sqlite-recurring-events/node_modules/drizzle-orm/sqlite-core/columns/integer.js:71:17) at /Users/nikos/WebstormProjects/drizzle-sqlite-recurring-events/node_modules/drizzle-orm/sql/sql.js:119:58 at map (:1:20) at buildQueryFromSourceParams (/Users/nikos/WebstormProjects/drizzle-sqlite-recurring-events/node_modules/drizzle-orm/sql/sql.js:72:24) at map (:1:20) at buildQueryFromSourceParams (/Users/nikos/WebstormProjects/drizzle-sqlite-recurring-events/node_modules/drizzle-orm/sql/sql.js:72:24) at map (:1:20) at buildQueryFromSourceParams (/Users/nikos/WebstormProjects/drizzle-sqlite-recurring-events/node_modules/drizzle-orm/sql/sql.js:72:24) at /Users/nikos/WebstormProjects/drizzle-sqlite-recurring-events/node_modules/drizzle-orm/sql/sql.js:52:20 at prepare (/Users/nikos/WebstormProjects/drizzle-sqlite-recurring-events/node_modules/drizzle-orm/sqlite-core/query-builders/insert.js:123:6) error: script "db:seed" exited with code 1 (SIGHUP) ➜ drizzle-sqlite-recurring-events git:(main) ✗

ephraimduncan commented 2 weeks ago

why is this closed? what is the fix?

mceachen commented 2 weeks ago

This is an issue with Drizzle--not with this library.

I'd suggest extracting the inline new Date(...).getTime() into a constant before the .insert call and seeing what happens, as the value.getTime() error is pretty nonsensical.

ephraimduncan commented 2 weeks ago

Okay thank you. My drizzle queries work fine but I'm using Lucia Auth and I get the error when Lucia is trying to create a new session