Drizzle ORM issues
Running into weird issue with ORM where
Query: select "id", "name", "email", "emailVerified", "image", "password", "role", "isNewUser", "invalidlogin_attempts", "lockedAt", "isTwoFactorEnabled", "created_at", "updated_at" from "dds_users" "users" where "users"."email" = $1 limit $2 -- params: ["xxx@gmail.com", 1]
⨯ TypeError: value.toISOString is not a function
at PgTimestamp.mapToDriverValue (C:\MyFiles\Saas\next-progress-saas.next\server\chunks\ssr\5f296_drizzle-orm_pg-core_f7448a..js:1958:22)
But NEON works
select "id", "name", "email", "emailVerified", "image", "password", "role", "isNewUser", "invalid_login_attempts", "lockedAt", "isTwoFactorEnabled", "created_at", "updated_at" from "dds_users" "users" where "users"."email" = 'xxx@gmail.com' limit 1
1 0f6f87da-2e4e-461a-9e35-d6dbbb5cec77 BrianT XXX xxx@gmail.com $2b$10$WZp3J0vsX8au5pGEw7HDluTDogz8xUOX64MLEuXZX1Ro14k539QF2 User t 0 f 2024-12-09 20:31:39.175528+00 2024-12-09 20:31:39.175528+00
1 Reply
The data was inserted by simple db.insert(users).values(name, email, password)
My schema export const users = createTable("users", {
id: text("id")
.primaryKey()
.default(sqlgen_random_uuid()),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
mode: "date",
withTimezone: true,
}),
image: varchar("image", { length: 255 }),
password: varchar("password", { length: 100 }),
role: varchar("role", { length: 255 }).default("User").notNull(),
isNewUser: boolean("isNewUser").default(true).notNull(),
invalid_login_attempts: integer("invalid_login_attempts")
.default(0)
.notNull(),
lockedAt: timestamp("lockedAt", {
mode: "date",
withTimezone: true,
}),
isTwoFactorEnabled: boolean("isTwoFactorEnabled").default(false).notNull(),
createdAt: timestamp("created_at", { withTimezone: true, mode: "date" })
.default(sql(now() AT TIME ZONE 'utc'::text))
.notNull(),
updatedAt: timestamp("updated_at", { withTimezone: true, mode: "date" })
.default(sql(now() AT TIME ZONE 'utc'::text))
.notNull()
.$onUpdate(() => sql(now() AT TIME ZONE 'utc'::text)),
})
After few hours: it appears that all caused by this .$onUpdate(() => sql(now() AT TIME ZONE 'utc'::text)), just left the index on updatedAt and it breaks. Drizzle-kit 0.30.0