Better HN
topnewbestaskshowjobs
Log inSign up

k972

1 karma · joined Nov 30, 2024 (1y ago) · 1 submissions

Submissions

comment 1y ago · link · parent

Depending on what database you're using, you might be able to restructure your dynamic queries to fit a static form...

WHERE ... AND CASE WHEN ? IS NULL THEN TRUE ELSE col ILIKE ? || '%' END AND CASE WHEN ? IS NULL THEN TRUE ELSE col2 IN (?) END

Each "dynamic" parameter is then bound twice. (My personal preference is to use a CTE to bind and name my parameter values in the query instead of binding multiple times whenever possible).