ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Teamโ€ข3y agoโ€ข
3 replies
Nicolas

How to make sql.placeholder() type safe

I have the following prepared statement:

export const listDeployments = db
  .select()
  .from(deployments)
  .where(eq(deployments.organizationId, sql.placeholder("orgId")))
  .prepare("listDeployments");
export const listDeployments = db
  .select()
  .from(deployments)
  .where(eq(deployments.organizationId, sql.placeholder("orgId")))
  .prepare("listDeployments");


However, when I use this like below:
const response = await listDeployments.execute({ orgId: input });
const response = await listDeployments.execute({ orgId: input });


The
orgId
orgId
is not type safe, I can enter whatever string I want, and there is no way to protect this call from receiving something other than
orgId
orgId


Is there a way to make it such that the caller must pass in
orgId
orgId
?

Thank you!
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

How to specify type using sql template
Drizzle TeamDTDrizzle Team / help
3y ago
sql placeholder with an array throws an error
Drizzle TeamDTDrizzle Team / help
2y ago
Raw sql nullable types, sql<Type | undefined>
Drizzle TeamDTDrizzle Team / help
3y ago
sql.placeholder not working for pg array of strings
Drizzle TeamDTDrizzle Team / help
3y ago