4 ms·
This is absolutely not the case. In fact I've never used an ORM myself that generates SQL directly – they all generate some kind of abstract model then render t
by matthewmacleod 3y ago
This is absolutely not the case. In fact I've never used an ORM myself that generates SQL directly – they all generate some kind of abstract model then render that to SQL using a database-specific adapter.
Specifically, Rails' ActiveRecord will transform e.g.
Customer.create(name: 'test')
into the following when using Postgres
INSERT INTO "customers" ("name") VALUES ('test') RETURNING "id";
Things like
Customer.upsert_all([{name: 'test'}])
will also work to perform upserts.
In practice, ORMs are more advanced than you might think, and can be a useful tool in some cases!