Broken typescript in select

Whatever I put inside the select function. it will generate this typescript error: I am using the lastest ts- and drizzle versions.
1 Reply
Eternal Mori
Eternal MoriOP2y ago
I fixed it, it was because I used a dynamic db connection:
import { connect } from "@planetscale/database";
import { type DrizzleConfig } from "drizzle-orm";
import { drizzle as mysqlDrizzle } from "drizzle-orm/mysql2";
import { drizzle as planetscaleDrizzle } from "drizzle-orm/planetscale-serverless";
import mysql from "mysql2/promise";

import * as schema from "~/lib/drizzle/schema";
import { env } from "~/env.mjs";

const isDev = env.NODE_ENV === "development";

const mysqlConnection = await mysql.createConnection({
uri: env.DATABASE_URL,
});

const planetscaleConnection = connect({
url: env.DATABASE_URL,
});

const config: DrizzleConfig<typeof schema> = {
schema,
logger: env.NODE_ENV === "development",
};

export const db = isDev
? mysqlDrizzle(mysqlConnection, config)
: planetscaleDrizzle(planetscaleConnection, config);
import { connect } from "@planetscale/database";
import { type DrizzleConfig } from "drizzle-orm";
import { drizzle as mysqlDrizzle } from "drizzle-orm/mysql2";
import { drizzle as planetscaleDrizzle } from "drizzle-orm/planetscale-serverless";
import mysql from "mysql2/promise";

import * as schema from "~/lib/drizzle/schema";
import { env } from "~/env.mjs";

const isDev = env.NODE_ENV === "development";

const mysqlConnection = await mysql.createConnection({
uri: env.DATABASE_URL,
});

const planetscaleConnection = connect({
url: env.DATABASE_URL,
});

const config: DrizzleConfig<typeof schema> = {
schema,
logger: env.NODE_ENV === "development",
};

export const db = isDev
? mysqlDrizzle(mysqlConnection, config)
: planetscaleDrizzle(planetscaleConnection, config);
Want results from more Discord servers?
Add your server