Re:What ORMs have taught me: just learn SQL (2014)
by ct520 on Friday September 20, 2019 @10:35PM
(#21033142)
So.. pattern I see emerging. Use orm for the common stuff and execute sql for complicated queries (like reports)
Re:What ORMs have taught me: just learn SQL (2014)
by JohnBooty on Saturday September 21, 2019 @02:15AM
(#21033810)
Ruby on Rails’ ActiveRecord, for all its heft, is excellent at this. You can use raw SQL any time you like. It was an explicit design goal from day 1.
There are times I dislike things about it, and it can be quite heavy, but it’s very easy to mix and match ActiveRecord ORM code and raw SQL even within a single model class.
Re:What ORMs have taught me: just learn SQL (2014)
by Trisell on Saturday September 21, 2019 @12:29AM
(#21033529)
That’s how I’ve done it on my last two projects. We used TypeORM for the standard repeated simple queries, and then wrote custom SQL for our complicated queries that the ORM failed at and then just executed them with the ORM. It was really nice and made for easier table refactors because we didn’t have to go through and audit every query that was calling that table.
Re:What ORMs have taught me: just learn SQL (2014)
by Rapzid on Saturday September 21, 2019 @04:01AM
(#21034088)
TypeORM is a step in the right direction for JS ORMs bit it's like 1/8th of the way there IMHO. A nearly fully typed ORM is possible now with Typescript and of course proxy's are out now.. TypeORM was doing too much ADHOC string building under the covers as well. I believe a SQL AST is the way to go. It can be transformed and compiled to database specific SQL allowing for things like predicate push down, optimization, and a sane way to implement db specific optimizations and extensions.
Re:What ORMs have taught me: just learn SQL (2014)
by nikolasburk on Saturday September 21, 2019 @04:28AM
(#21034160)
I really like your point about type-safety! I think one major issue with the current ORMs in the Node.js/TypeScript ecosystem (Sequelize, TypeORM, ...) is that they're not fully type-safe. As you mention, TypeORM is definitely a step into the right direction here, but the way how it leverages the TypeScript type system isn't where it could be. I work at Prisma where we're building [Photon.js][1], an auto-generated database client with a fully type-safe data access API.
Re:What ORMs have taught me: just learn SQL (2014)
by leosarev on Saturday September 21, 2019 @02:32AM
(#21033862)
Actually, DDD recommends that domain object in general should be loaded by id only, and complicated query for grid should load projection
Re:What ORMs have taught me: just learn SQL (2014)
by scarface74 on Saturday September 21, 2019 @01:57AM
(#21033755)
And for ETL and data loads. An ORM isn’t going to usually do a multi insert statement or an update that involves more than one table.
There is no real abstraction. You write standard SQL and it maps your recordset to an object. You know exactly what code is running.
There are extensions that will take a POCO object and create an insert statement and I believe updates, but where ORMs usually get obtuse and do magic are Selects. It’s hard to generate a suboptimal Insert or Update.