5 ms·
I agree to an extent. But, I disagree that learning ORMs are a waste of time. For example, I'm on Phoenix, using Ecto. I find `Repo.all` much more convenient t
by neya 7y ago
I agree to an extent. But, I disagree that learning ORMs are a waste of time. For example, I'm on Phoenix, using Ecto. I find
`Repo.all` much more convenient that "SELECT * FROM .." etc.
I don't know if it's better or worse - the original blog post asking governments to regulate data formats/code!
- chrisan 7y agoAs long as the ORM lets you pass raw SQL when needed I'm fine with some nice convenience methods for the majority of the work. When it comes to really complex stuff that you are just ending up fighting the ORM and its choice of SQL is when I get frustrated and go to plain ol SQL
- pdimitar 7y agoWell, Ecto is not an ORM. It's a Data Mapper[0]. Rails' ActiveRecord is ORM. I agree that some DSLs make SQL better and easier to reason about -- and that Ecto is one of them. [0] https://en.wikipedia.org/wiki/Data_mapper_pattern https://en.wikipedia.org/wiki/Data_mapper_pattern
- spdionis 7y agoAren't data mappers generally referred to as ORMs?
- pdimitar 7y agoNot to my knowledge. Data Mappers should be the "less batteries included" piece of tech compared to the ORMs. As a single non-representative example, ActiveRecord has `before_insert` hooks you can simply add as methods to your model class. Ecto doesn't have those.
- jrochkind1 7y agoThat seems silly. They are a technology for mapping from a relational database to a system based on objects. That's what an ORM is. > Data Mapper: A layer of Mappers (473) that moves data between objects and a database... (https://martinfowler.com/eaaCatalog/dataMapper.html https://martinfowler.com/eaaCatalog/dataMapper.html) Sounds like an ORM to me. Some people try to distinguish between the "data mapper" pattern and the "active record" pattern (it's not just the name of the Rails library, it's a pattern... which the Rails library may or may not implement very well). Both are ORMs, because both are ways of mapping from an rdbms to an object system. (Neither of which actually has to do with query DSL. We could imagine just taking the part of ActiveRecord that produces queries, but having it return simple hash/string literals. It wouldn't really be an "ORM" (except in the most technical sense that even hashes are objects in ruby), but it would still have the parts you don't like. The nature of query building is actually not related to 'data mapper' vs 'active record' -- you could have an instance of either in which you wrote raw SQL queries, or an instance of either which used the same non-SQL DSL)). But even distinguishing between "data mapper" and "active record", in actual practice, I don't think there are two completely separate, distinct, and unified camps. I don't think these categories actually serve well to deliniate the ORMs we've got. Instead, there are a just a whole bunch of approaches, some more light weight than others, some more mature/reliable than others, some 'leakier' than others, differing on all sorts of additional dimensions. I agree that some ORMs are better than others -- and some may disagree on which these are -- I don't think saying "data mapper" is actually useful for understanding which these are.