Open
Description
What version of drizzle-orm
are you using?
0.29.0
What version of drizzle-kit
are you using?
0.20.0
Describe the Bug
When initilizing drizzle the following way:
import { drizzle as drizzleD1, DrizzleD1Database } from 'drizzle-orm/d1'
import { drizzle, BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'
// @ts-ignore
import Database from 'better-sqlite3'
import { join } from 'pathe'
export * as tables from '~/server/db/schema'
import * as schema from '~/server/db/schema'
let _db: DrizzleD1Database<typeof schema> | BetterSQLite3Database<typeof schema> | null = null
export const db = new Database(join(process.cwd(), '/db.sqlite'))
export const useDB = () => {
if(!_db) {
if (process.env.DB) {
// d1 in production
_db = drizzleD1(process.env.DB, {schema})
return _db
} else if (process.dev) {
_db = drizzle(db, {schema})
return _db
} else {
throw new Error('No database configured for production')
}
} else return _db
}
and then using drizzle with partial select like the following:
return useDB().select({
id: job.id,
slug: job.slug,
title: job.title,
type: job.type,
location: job.location,
company: company.name,
closedAt: job.closedAt,
}).from(job)
.innerJoin(savedJobsForUser, eq(savedJobsForUser.jobId, job.id))
.innerJoin(company, eq(company.id, job.company_id))
.where(eq(savedJobsForUser.userId, userId))
.all()
i get the following TS Error: Expected 0 arguments, but got 1.
for the select part of the query.
This is the type of the select:
BaseSQLiteDatabase<TResultKind extends "async" | "sync", TRunResult, TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = ExtractTablesWithRelations<TFullSchema>>.select(): SQLiteSelectBuilder<undefined, "sync", RunResult, "db"> | SQLiteSelectBuilder<undefined, "async", D1Result, "db">
Expected behavior
That there should be no TS error and the types can be inferred from the query.
Environment & setup
Nuxt 3.7.3 with Nitro 2.6.3
better-sqlite3: 8.4.0,