© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
2 replies
francis

How to include array literals in raw sql?

I have an input array used for an order by using the array_position function - rather than passing the array as a single param, the call to:
.orderBy(sql`array_position(${ingredientNames}, ${entity.name})`);
.orderBy(sql`array_position(${ingredientNames}, ${entity.name})`);


generates a param list for each item in the input array. This generates a record rather than an array literal in Postgres.

Trying raw sql with:
`{${array.map((item) => `'${item}'`).join(",")}}`
`{${array.map((item) => `'${item}'`).join(",")}}`

doesn't work either.
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.raw with params array
Drizzle TeamDTDrizzle Team / help
14mo ago
raw SQL in schema
Drizzle TeamDTDrizzle Team / help
2y ago
Raw sql in schema
Drizzle TeamDTDrizzle Team / help
2y ago
How to convert sql.raw`` to camelCase?
Drizzle TeamDTDrizzle Team / help
2y ago