3 ms·
>If your SQL has to be computed at compile time, how do you implement any sort of search where you will have a variable number of ANDS & ORs? It's not your SQL
by coldtea 9y ago
>If your SQL has to be computed at compile time, how do you implement any sort of search where you will have a variable number of ANDS & ORs?
It's not your SQL (e.g. whole query) that needs to be computed at compile time, but the proper escaping of placeholder parameters.
So, the answer is: trivially.
- michaelmior 9y agoIn many cases that may be true, but not in the case of the parent comment you're responding to. The parent identifies a scenario where you have a faceted search functionality that generates conditions in the where clause of the query dynamically).
- coldtea 9y agoSo? What prevents those conditions to be generated as a number of SQL fragments that are statically checked for injection? What would be checked by Rust is the actual fitness of the fragments, not if your building them in a loop from pre-made WHERE, AND etc clauses + placeholders.
- michaelmior 9y agoDefinitely possible. Just more nuanced than the approach suggested in the article.