Need help with 'onConflictDoUpdate' method

Hello, I'm using 'drizzle-orm/neon-serverless' package with Postgres database When using onConflicDoUpdate method, I got this error "column reference "column_name" is ambiguous" Here is my code :
const upsertLead = await db
.insert(lead)
.values(leadsInfo)
.onConflictDoUpdate({
target: lead.phone,
set: {
email: leadsInfo.email,
firstName: leadsInfo.firstName,
},
})
.returning()
.execute();
const upsertLead = await db
.insert(lead)
.values(leadsInfo)
.onConflictDoUpdate({
target: lead.phone,
set: {
email: leadsInfo.email,
firstName: leadsInfo.firstName,
},
})
.returning()
.execute();
Here is my "lead" table definiton :
export const lead = createTable(
"lead",
{
id: serial("id").primaryKey(),
type: varchar("type", { length: 255 }).notNull(),
firstName: varchar("first_name", { length: 255 }).notNull(),
lastName: varchar("last_name", { length: 255 }).notNull(),
phone: varchar("phone", { length: 255 })
.notNull()
.unique("uniqueLeadPhone"),
email: varchar("email", { length: 255 }).notNull(),
createdById: integer("created_by_id")
.notNull()
.references(() => users.id),
lastModifiedById: integer("last_modified_by_id")
.notNull()
.references(() => users.id),
createdAt: timestamp("created_at", {
precision: 3,
withTimezone: true,
}).default(sql`CURRENT_TIMESTAMP`),
updatedAt: timestamp("updated_at", {
precision: 3,
withTimezone: true,
}).default(sql`CURRENT_TIMESTAMP`),
},
);
export const lead = createTable(
"lead",
{
id: serial("id").primaryKey(),
type: varchar("type", { length: 255 }).notNull(),
firstName: varchar("first_name", { length: 255 }).notNull(),
lastName: varchar("last_name", { length: 255 }).notNull(),
phone: varchar("phone", { length: 255 })
.notNull()
.unique("uniqueLeadPhone"),
email: varchar("email", { length: 255 }).notNull(),
createdById: integer("created_by_id")
.notNull()
.references(() => users.id),
lastModifiedById: integer("last_modified_by_id")
.notNull()
.references(() => users.id),
createdAt: timestamp("created_at", {
precision: 3,
withTimezone: true,
}).default(sql`CURRENT_TIMESTAMP`),
updatedAt: timestamp("updated_at", {
precision: 3,
withTimezone: true,
}).default(sql`CURRENT_TIMESTAMP`),
},
);
Maybe someone already get this error ?
1 Reply
Anthony BETTOLLO
Anthony BETTOLLOOP9mo ago
Solved this was about our trigger
Want results from more Discord servers?
Add your server