Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamβ€’2y agoβ€’
3 replies
wisie

sql placeholder with an array throws an error

when executing this code:
const prepQuery = db
  .select()
  .from(table)
  .where(inArray(table.postId, sql.placeholder("postIds")))
  .prepare("prepquery");

const result = await prepQuery.execute({
  postIds: ["esaeasdas", "esaeasdas", "esaeasdas"]
})
const prepQuery = db
  .select()
  .from(table)
  .where(inArray(table.postId, sql.placeholder("postIds")))
  .prepare("prepquery");

const result = await prepQuery.execute({
  postIds: ["esaeasdas", "esaeasdas", "esaeasdas"]
})

Drizzle throws an error:
syntax error at or near \"$1\
syntax error at or near \"$1\
. The code works when I execute the prepared query without the sql.placeholder, hardcoding an argument inside
prepQuery
prepQuery
- the error is not reproduced anyway else. Do I need to pass the array of strings there differently? I tried converting it into a string, but that does not work neither.
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

sql.placeholder not working for pg array of strings
Drizzle TeamDTDrizzle Team / help
3y ago
sql.raw with params array
Drizzle TeamDTDrizzle Team / help
14mo ago
Using a placeholder with an inArray
Drizzle TeamDTDrizzle Team / help
3y ago
sql operator with array of strings
Drizzle TeamDTDrizzle Team / help
2y ago