No Overload Matches this call on insert

Hello, I get an error when I try to select to a table, Here is the error I get:
│ E No overload matches this call. typescript (2769) [63, 5]
│ Overload 1 of 3, '(left: Column<ColumnBaseConfig<ColumnDataType, string>, object, object>, right: unknown): SQL<unknown>', gave the following error.
│ Argument of type 'number' is not assignable to parameter of type 'Column<ColumnBaseConfig<ColumnDataType, string>, object, object>'.
│ Overload 2 of 3, '(left: Aliased<SQLiteColumn<{ name: "userId"; tableName: "waitlists"; dataType: "number"; columnType: "SQLiteInteger"; data: number; driverParam: number; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, object>>, right: SQLWrapper | SQLiteColumn<...>): SQL<...>', gave the following error.
│ Argument of type 'number' is not assignable to parameter of type 'Aliased<SQLiteColumn<{ name: "userId"; tableName: "waitlists"; dataType: "number"; columnType: "SQLiteInteger"; data: number; driverParam: number; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, object>>'.
│ Overload 3 of 3, '(left: SQLWrapper, right: unknown): SQL<unknown>', gave the following error.
│ Argument of type 'number' is not assignable to parameter of type 'SQLWrapper'.

│ E No overload matches this call. typescript (2769) [63, 5]
│ Overload 1 of 3, '(left: Column<ColumnBaseConfig<ColumnDataType, string>, object, object>, right: unknown): SQL<unknown>', gave the following error.
│ Argument of type 'number' is not assignable to parameter of type 'Column<ColumnBaseConfig<ColumnDataType, string>, object, object>'.
│ Overload 2 of 3, '(left: Aliased<SQLiteColumn<{ name: "userId"; tableName: "waitlists"; dataType: "number"; columnType: "SQLiteInteger"; data: number; driverParam: number; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, object>>, right: SQLWrapper | SQLiteColumn<...>): SQL<...>', gave the following error.
│ Argument of type 'number' is not assignable to parameter of type 'Aliased<SQLiteColumn<{ name: "userId"; tableName: "waitlists"; dataType: "number"; columnType: "SQLiteInteger"; data: number; driverParam: number; notNull: true; hasDefault: false; enumValues: undefined; baseColumn: never; }, object>>'.
│ Overload 3 of 3, '(left: SQLWrapper, right: unknown): SQL<unknown>', gave the following error.
│ Argument of type 'number' is not assignable to parameter of type 'SQLWrapper'.

here is the function where I get the error:
export async function getWaitlists() {
const user = await getUser();
if (!user.clerkId) throw new Error("Unauthorized")

const result = await db.select().from(waitlists).where(eq(
user.id,
waitlists.userId
))

return result;
};
export async function getWaitlists() {
const user = await getUser();
if (!user.clerkId) throw new Error("Unauthorized")

const result = await db.select().from(waitlists).where(eq(
user.id,
waitlists.userId
))

return result;
};
5 Replies
Babadur
BabadurOP7mo ago
I am getting it on the user.id line. Here is my user and waitlist schema:
export const users = sqliteTable("users", {
id: integer("id").primaryKey().notNull().unique(),
clerkId: text("clerkId").notNull().unique(),
email: text("email").notNull(),
tier: text("tier", { enum: ["free", "pro", "enterprise"] }).default("free"),
firstName: text("firstName").notNull(),
numWaitlists: integer("numWaitlists"),
createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`),
});
export const users = sqliteTable("users", {
id: integer("id").primaryKey().notNull().unique(),
clerkId: text("clerkId").notNull().unique(),
email: text("email").notNull(),
tier: text("tier", { enum: ["free", "pro", "enterprise"] }).default("free"),
firstName: text("firstName").notNull(),
numWaitlists: integer("numWaitlists"),
createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`),
});
export const waitlists = sqliteTable("waitlists", {
id: integer("id").primaryKey().notNull().unique(),
userId: integer("userId")
.notNull()
.references(() => users.id),
limit: integer("limit"),
count: integer("count").default(0),
createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`),
updatedAt: text("updated_at").default(sql`CURRENT_TIMESTAMP`).$onUpdate(() => sql`CURRENT_TIMESTAMP`),
title: text("title").notNull(),
color: text("color"),
video: text("video"),
copy: text("copy").notNull()
});
export const waitlists = sqliteTable("waitlists", {
id: integer("id").primaryKey().notNull().unique(),
userId: integer("userId")
.notNull()
.references(() => users.id),
limit: integer("limit"),
count: integer("count").default(0),
createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`),
updatedAt: text("updated_at").default(sql`CURRENT_TIMESTAMP`).$onUpdate(() => sql`CURRENT_TIMESTAMP`),
title: text("title").notNull(),
color: text("color"),
video: text("video"),
copy: text("copy").notNull()
});
Here is my getUser function:
export async function getUser() {
const user = auth()

if (!user.userId) throw new Error("Unauthorized")

const clerkId = user.userId;

console.log("here")

const result = await db.select().from(users).where(eq(users.clerkId, clerkId));

console.log(result[0])
return result[0]
}
export async function getUser() {
const user = auth()

if (!user.userId) throw new Error("Unauthorized")

const clerkId = user.userId;

console.log("here")

const result = await db.select().from(users).where(eq(users.clerkId, clerkId));

console.log(result[0])
return result[0]
}
Angelelz
Angelelz7mo ago
Is the error on an insert or a select?
Babadur
BabadurOP7mo ago
it is on a select yeah sorry I said insert, its actually on a select, I changed just edited the original message
Angelelz
Angelelz7mo ago
What happens if you swap the order of the parameters your are passing to the eq function?
Babadur
BabadurOP7mo ago
that removed the error, thanks! I was also getting it for another field and I tried swapping it around too but it didnt fix it so I just casted it as any.
Want results from more Discord servers?
Add your server