Cannot prepare a statement for table update

Trying to make a prepared statement for updating user's subscription but getting errors:
export const preparedSetSubscriptionStatement = db
.update(userSchema)
.set({
subscriptionTierId: sql.placeholder('subscriptionTierId'),
subscriptionTierPrice: sql.placeholder('subscriptionTierPrice'),
subscriptionTierStartedAt: sql`CURRENT_TIMESTAMP`,
})
.where(eq(userSchema.id, sql.placeholder('id')))
.prepare('user_set_subscription');
export const preparedSetSubscriptionStatement = db
.update(userSchema)
.set({
subscriptionTierId: sql.placeholder('subscriptionTierId'),
subscriptionTierPrice: sql.placeholder('subscriptionTierPrice'),
subscriptionTierStartedAt: sql`CURRENT_TIMESTAMP`,
})
.where(eq(userSchema.id, sql.placeholder('id')))
.prepare('user_set_subscription');
Errors for subscriptionTierId and subscriptionTierPrice set fields:
Type 'Placeholder<"subscriptionTierId", any>' is not assignable to type 'number | SQL<unknown> | null | undefined'.
Type 'Placeholder<"subscriptionTierId", any>' is missing the following properties from type 'SQL<unknown>': queryChunks, _, shouldInlineParams, append, and 7 more.ts(2322)
schema.ts(29, 3): The expected type comes from property 'subscriptionTierId' which is declared here on type '<redacted, fields from userSchema>'
Type 'Placeholder<"subscriptionTierId", any>' is not assignable to type 'number | SQL<unknown> | null | undefined'.
Type 'Placeholder<"subscriptionTierId", any>' is missing the following properties from type 'SQL<unknown>': queryChunks, _, shouldInlineParams, append, and 7 more.ts(2322)
schema.ts(29, 3): The expected type comes from property 'subscriptionTierId' which is declared here on type '<redacted, fields from userSchema>'
Type 'Placeholder<"subscriptionTierPrice", any>' is not assignable to type 'string | SQL<unknown> | null | undefined'.
Type 'Placeholder<"subscriptionTierPrice", any>' is missing the following properties from type 'SQL<unknown>': queryChunks, _, shouldInlineParams, append, and 7 more.ts(2322)
schema.ts(30, 3): The expected type comes from property 'subscriptionTierPrice' which is declared here on type '<redacted, fields from userSchema>'
Type 'Placeholder<"subscriptionTierPrice", any>' is not assignable to type 'string | SQL<unknown> | null | undefined'.
Type 'Placeholder<"subscriptionTierPrice", any>' is missing the following properties from type 'SQL<unknown>': queryChunks, _, shouldInlineParams, append, and 7 more.ts(2322)
schema.ts(30, 3): The expected type comes from property 'subscriptionTierPrice' which is declared here on type '<redacted, fields from userSchema>'
1 Reply
Angelelz
Angelelz7mo ago
I'm not sure placeholders are yet supported in update statements
Want results from more Discord servers?
Add your server