10 ms·
I think the best ORMs are those that just leave out the "Relational" part entirely. So... "OM"? For example, in Go, I use Gorp, which has a Select() function w
by majewsky 9y ago
I think the best ORMs are those that just leave out the "Relational" part entirely. So... "OM"?
For example, in Go, I use Gorp, which has a Select() function where you pass in the SELECT query string (plus bound values) and the target type, and it loads every result row into an object of that type. So you can have an arbitrarily complex SQL query as long as it starts with `SELECT one_table.* FROM`. That's a marvelous design.
And when you have to do a query that returns results from multiple tables? Guess what, you just use the normal SQL module from the standard library.
- scarface74 9y agoWhy is it an either or? EF can do that but then you loose the benefits of a type safe language.
- oceanswave 9y agoIf type safety is so great, why isn’t sql statically type checked
- majewsky 9y agoSQL is statically type-checked, at least in Postgres. postgres=# SELECT * FROM domains WHERE id = 'foo'; ERROR: invalid input syntax for integer: "foo" LINE 1: SELECT * FROM domains WHERE id = 'foo'; ^
- cpfohl 9y agoNot just PostGres. That's standard SQL. Columns have data types. Tables have schemata. Schemata are very strongly typed. Can't insert a 'full_name' column into a table without such a column.
- da_chicken 9y agoUnless you're talking about SQLite, SQL RDBMSs are both static and strongly typed. The systems typically do allow some implicit type conversions, but type is critical to how a table works.
- lmm 9y agoBecause SQL predates a lot of modern techniques. A ground-up replacement written today probably would be statically type checked.