Placeholder does not work properly with update

const update = db
.update(userTable)
.set({ name: sql.placeholder('name') })
.where(eq(userTable.id, sql.placeholder('id')))
.prepare('updateUser');
const update = db
.update(userTable)
.set({ name: sql.placeholder('name') })
.where(eq(userTable.id, sql.placeholder('id')))
.prepare('updateUser');
Is there a workaround to this?
7 Replies
Angelelz
Angelelz10mo ago
Can you provide more information?
CrisOG
CrisOGOP10mo ago
For sure, 1 sec. it's a type error though
CrisOG
CrisOGOP10mo ago
This is where the error pops up, and this is the whole error:
Type 'Placeholder<"name", any>' is not assignable to type 'string | SQL<unknown> | null | undefined'.
Type 'Placeholder<"name", any>' is missing the following properties from type 'SQL<unknown>': queryChunks, _, shouldInlineParams, append, and 6 more.ts(2322)
Type 'Placeholder<"name", any>' is not assignable to type 'string | SQL<unknown> | null | undefined'.
Type 'Placeholder<"name", any>' is missing the following properties from type 'SQL<unknown>': queryChunks, _, shouldInlineParams, append, and 6 more.ts(2322)
No description
CrisOG
CrisOGOP10mo ago
This is the schema for user
export const userTable = pgTable('user', {
id: text('id').primaryKey(),
name: text('name'),
role: roleEnum('role').notNull().default('user'),
createdAt: timestamp('createdAt').notNull().defaultNow(),
updatedAt: timestamp('updatedAt').notNull().defaultNow()
});
export const userTable = pgTable('user', {
id: text('id').primaryKey(),
name: text('name'),
role: roleEnum('role').notNull().default('user'),
createdAt: timestamp('createdAt').notNull().defaultNow(),
updatedAt: timestamp('updatedAt').notNull().defaultNow()
});
Angelelz
Angelelz10mo ago
GitHub
Fix: allow enums (and any other column) to accept placeholders on u...
close #1608 [All] Added placeholder to the accepted types of the values of the update [All] Added tests Please note that this is only a type change, nothing is done on runtime to prevent the user...
Angelelz
Angelelz10mo ago
For now you can just ignore the type error
CrisOG
CrisOGOP10mo ago
Thank you <:peepo_sip:1147455108834152478>
Want results from more Discord servers?
Add your server