3 ms·
I'm firmly on the side of raw queries with binding params to avoid SQL injection. This is doubly true with complex queries. I can't count how many times I've cr
by sethammons 9y ago
I'm firmly on the side of raw queries with binding params to avoid SQL injection. This is doubly true with complex queries. I can't count how many times I've crafted my SQL query very quickly, and then fought the ORM query builder.
Often, ORM proponents will say that is why any true Scotsman, erm, I mean ORM, will let you drop into raw mode. But that can have problems with testing. If you test against your ORM one way, it might just not work to test it against raw mode. And, thinking of testing, I'm also a fan of testing your SQL or ORM against a real DB (one that is set up and tore down per test). I know there are some unit testing purests that don't like that and thus prefer an ORM.
Many who like ORMs claim that they are so much faster for the programmer. Maybe for basic CRUD and composing simple conditional WHERE statements. And I contend that really is a "maybe." But I've been bit by poorly formed ORM queries (either does not do what you planned or is too slow, or one of my favorites: it returns ALL records and the ORM filters that app side to give you the ONE matching result) and I've lost enough time trying to force the ORM to make the query the way I want it, that I opt to skip that whole class of problem whenever I can.
- mosselman 9y agoFunny, calling people out on ‘ no true Scotsman’ in your straw man reasoning.
- sethammons 9y agoIs it a straw man when you bring up regular arguments you've heard? I was under the impression that a straw man happened when you side stepped an opposing view by presenting a different argument. Since I wasn't side stepping an argument of the op's, is it still a straw man? If so, how does one present their opinions in comparison to others without automatically falling into a straw man situation?