customType causing type error when performing operation on table

I have a simple customType to use the citext extension in Postgres.
import { customType } from "drizzle-orm/pg-core";

export const citext = customType<{ data: string; driverData: string }>({
dataType() {
return "citext";
},
});
import { customType } from "drizzle-orm/pg-core";

export const citext = customType<{ data: string; driverData: string }>({
dataType() {
return "citext";
},
});
This is fine in my table:
export const access = pgTable("access", {
email: citext("email").primaryKey(),
});
export const access = pgTable("access", {
email: citext("email").primaryKey(),
});
But when I try to use the table (e.g. db.select().from(access)), I get the following error:
Argument of type 'PgTableWithColumns<{ name: "access"; schema: undefined; columns: { email: PgColumn<{ name: "email"; tableName: "access"; dataType: "custom"; columnType: "PgCustomColumn"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>; }; dialect: "pg"; }>' is not assignable to parameter of type 'AnyPgTable<{}> | Subquery<string, unknown> | PgViewBase<string, boolean, ColumnsSelection> | SQL<unknown>'.

Type 'PgTable<{ name: "access"; schema: undefined; columns: { email: PgColumn<{ name: "email"; tableName: "access"; dataType: "custom"; columnType: "PgCustomColumn"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>; }; dialect: "pg"; }> & { ...; }' is missing the following properties from type 'SQL<unknown>': queryChunks, shouldInlineParams, append, toQuery, and 5 more.
Argument of type 'PgTableWithColumns<{ name: "access"; schema: undefined; columns: { email: PgColumn<{ name: "email"; tableName: "access"; dataType: "custom"; columnType: "PgCustomColumn"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>; }; dialect: "pg"; }>' is not assignable to parameter of type 'AnyPgTable<{}> | Subquery<string, unknown> | PgViewBase<string, boolean, ColumnsSelection> | SQL<unknown>'.

Type 'PgTable<{ name: "access"; schema: undefined; columns: { email: PgColumn<{ name: "email"; tableName: "access"; dataType: "custom"; columnType: "PgCustomColumn"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, {}, {}>; }; dialect: "pg"; }> & { ...; }' is missing the following properties from type 'SQL<unknown>': queryChunks, shouldInlineParams, append, toQuery, and 5 more.
Custom type documentation is very limited. Has something changed here or am I doing something wrong?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server