TS error: Argument of type PgTableWithColumns is not assignable to parameter of type AnyPgTable

Hi all, after updating to latest i'm getting this TS error. This is my db creation and schema.
import { User } from './schemas/user';

const queryClient = postgres(DATABASE_URL);

const db = drizzle(queryClient, { schema: { User } });
export type DB = typeof db;

db.select().from(User);
import { User } from './schemas/user';

const queryClient = postgres(DATABASE_URL);

const db = drizzle(queryClient, { schema: { User } });
export type DB = typeof db;

db.select().from(User);
3 Replies
jpcafe
jpcafeOP2y ago
Repro extracted from the getting started docs
import { pgTable, serial, text, varchar } from 'drizzle-orm/pg-core';

export const users = pgTable('users', {
id: serial('id').primaryKey(),
fullName: text('full_name'),
phone: varchar('phone', { length: 256 })
});

import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';

const client = postgres('');
const db = drizzle(client);

const allUsers = await db.select().from(users);
import { pgTable, serial, text, varchar } from 'drizzle-orm/pg-core';

export const users = pgTable('users', {
id: serial('id').primaryKey(),
fullName: text('full_name'),
phone: varchar('phone', { length: 256 })
});

import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';

const client = postgres('');
const db = drizzle(client);

const allUsers = await db.select().from(users);
Maston
Maston2y ago
can't personally reproduce with drizzle-orm v0.26.0 postgres 3.3.4
jpcafe
jpcafeOP2y ago
i think the error is now gone i've installed from fresh!
Want results from more Discord servers?
Add your server