Incorrect return type findFrist

QQube1175/20/2023
Hi! I just upgraded to 26.0 and I'm refactoring queries to findFirst where needed. But the return type is not correctly inferred! The return type is just
const user: {
[x: string]: never;
} | undefined
const user: {
[x: string]: never;
} | undefined
see https://imgur.com/a/BlYG4Mj users schema:
export const users = mysqlTable(
'auth_user', {
id: serial('id').primaryKey().notNull(),
email: varchar('email', { length: 191 }).notNull(),
emailVerified: timestamp('emailVerified'),
verificationCode: varchar('verificationCode', { length: 255 }),
},
(user) => ({
emailIndex: uniqueIndex('users__email__idx').on(user.email),
verificationCodeIndex: uniqueIndex('users__verificationCode__idx').on(user.verificationCode),
}),
)
export const users = mysqlTable(
'auth_user', {
id: serial('id').primaryKey().notNull(),
email: varchar('email', { length: 191 }).notNull(),
emailVerified: timestamp('emailVerified'),
verificationCode: varchar('verificationCode', { length: 255 }),
},
(user) => ({
emailIndex: uniqueIndex('users__email__idx').on(user.email),
verificationCodeIndex: uniqueIndex('users__verificationCode__idx').on(user.verificationCode),
}),
)
I'm using mysql with the planetscale adapter
ASAndrii Sherman5/20/2023
Can you show drizzle db creation and imports for it?
QQube1175/20/2023
This is my db.ts file
import { drizzle } from 'drizzle-orm/planetscale-serverless'
import { connect } from '@planetscale/database'
import { serverEnv } from '$lib/server/serverEnv'

// create the connection
export const connection = connect({
host: serverEnv.DATABASE_HOST,
username: serverEnv.DATABASE_USERNAME,
password: serverEnv.DATABASE_PASSWORD,
})

export const db = drizzle(connection)
import { drizzle } from 'drizzle-orm/planetscale-serverless'
import { connect } from '@planetscale/database'
import { serverEnv } from '$lib/server/serverEnv'

// create the connection
export const connection = connect({
host: serverEnv.DATABASE_HOST,
username: serverEnv.DATABASE_USERNAME,
password: serverEnv.DATABASE_PASSWORD,
})

export const db = drizzle(connection)
and I just import it justing import { db } from '$lib/db/db' (i'm using sveltekit $ is just an allias)
ASAndrii Sherman5/20/2023
You need to pass your tables and relations to 2nd param of drizzle() You can check: https://orm.drizzle.team/docs/rqb
QQube1175/20/2023
Whoops totally my fault! I was too hyped, and completely missed that part

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
Relations module - or conditionHi there! I have a teams table, an users table, and a team_members table that connects these two. AAre foreign key polyfills for PlanetScale supported by Drizzle?Hi Prisma supports this (although slow). See: https://www.prisma.io/docs/guides/database/planetscalTS error: Argument of type PgTableWithColumns is not assignable to parameter of type AnyPgTableHi all, after updating to latest i'm getting this TS error. This is my db creation and schema. ``` Many-to-many relational query issuesschema, relations, statements: https://gist.github.com/kylewardnz/37104f989807e96555ea856294a2b670 drizzle-kit: push wants to change column type that hasn't changedjust updated my dependencies: ``` dependencies: - drizzle-orm 0.25.4 + drizzle-orm 0.26.0 devDependedrizzle-kit doesn't seems picking up the default config TS (up:pg)Hi I'd like to report that the latest drizzle-kit `0.18.0` doesn't seems to detect my `drizzle.confBuild queries dynamically with conditions.How to build query on the basis of if-else conditions? I have tried doing it as below ``` let dbQuerdrizzle-kit: Error: Cannot find module 'drizzle-orm/version'Hi there, when I run the following command: `pnpx drizzle-kit generate:pg`, I get the following erroConditional logic within template strings not supported on raw MySQL queryI am trying to execute raw SQL query with some conditional logic but it always fails. It's working fexecuting an `update` statement does not use `.onUpdateNow()` defined in schemaHello everyone 🙂 I have the following schema for my `USERS` table: ```ts export const users = mysq