4 ms·
The other way to fight things like this that however you want your users to behave should be the most straightforward way to use the code. If you library provid
by hinkley 7y ago
The other way to fight things like this that however you want your users to behave should be the most straightforward way to use the code. If you library provides shortcuts to bad behavior, people will take them.
I was just rereading you comments and started searching for SQL linters and thinking how hard that would be in practice due to all the ways the queries get muddled in imperative code and a thought came to mind:
One of the ways we reduce people’s reliance on string concatenation is by providing interpolation. And I think that at least in some languages you can substitute your own logic for interpolation. You might be able to encourage bind variables that way.
SELECT * FROM users
WHERE last_name=${surname} AND age>${legalDrinkingAge(state)}
ORDER BY birthdate ASC
- hansvm 7y agoThis is mostly how entity framework behaves. Last I checked they had some sort of nonsense checking whether a variable was in _any_ closure before deciding whether to bind it or substitute it, but give or take the rough edges it will bind variables provided in parameterized strings.