Greenman999
Greenman999
Explore posts from servers
SSolidJS
Created by Greenman999 on 6/22/2024 in #support
this is undefined
No description
4 replies
DTDrizzle Team
Created by Greenman999 on 6/21/2024 in #help
`Argument of type 'SQL<unknown>' is not assignable to parameter of type 'IndexColumn'.`
Hello I am creating a schema like this guide (https://orm.drizzle.team/learn/guides/unique-case-insensitive-email) but i get the error in the title on .on(lower(table.email)). This is my code:
import { SQL, sql } from "drizzle-orm";
import {
AnyPgColumn,
pgTable,
timestamp,
uniqueIndex,
uuid,
varchar,
} from "drizzle-orm/pg-core";

export const users = pgTable(
"users",
{
id: uuid("id").defaultRandom().notNull().primaryKey(),
email: varchar("email", { length: 256 }).notNull(),
username: varchar("username", { length: 16 }).notNull(),
displayname: varchar("displayname", { length: 32 }).notNull(),
created_at: timestamp("created_at", { mode: "date" }).notNull(),
},
(table) => ({
emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)),
usernameUniqueIndex: uniqueIndex("usernameUniqueIndex").on(lower(table.username))
}),
);

export function lower(email: AnyPgColumn): SQL {
return sql`lower(${email})`;
}
import { SQL, sql } from "drizzle-orm";
import {
AnyPgColumn,
pgTable,
timestamp,
uniqueIndex,
uuid,
varchar,
} from "drizzle-orm/pg-core";

export const users = pgTable(
"users",
{
id: uuid("id").defaultRandom().notNull().primaryKey(),
email: varchar("email", { length: 256 }).notNull(),
username: varchar("username", { length: 16 }).notNull(),
displayname: varchar("displayname", { length: 32 }).notNull(),
created_at: timestamp("created_at", { mode: "date" }).notNull(),
},
(table) => ({
emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)),
usernameUniqueIndex: uniqueIndex("usernameUniqueIndex").on(lower(table.username))
}),
);

export function lower(email: AnyPgColumn): SQL {
return sql`lower(${email})`;
}
2 replies