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

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),
    }),
)


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)

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