|
|
|
|
|
by rocho
2457 days ago
|
|
I have the opposite view. I find ORMs annoying and obscure, and I think they introduce duplicated code. If you need to run a certain query in multiple places, you need to repeat the same ORM expression or refractor it into a function. I find much better to have a module with all my SQL queries as strings. That way whenever I need to run a query I reference it from there. Of course it helps to use meaningful names. This approach has a lot of advantages over ORMs:
* you know exactly what gets executed
* automatic DRY code
* the names of the SQL queries in the code are self-explanatory and the reader doesn't have to parse the ORM expression every time Schema definitions are in standalone SQL files, as well as my migrations. The only disadvantage is that it may be difficult to switch to a different database system, but that is not a problem for us. |
|