lambdaclass / concrete

Concrete is a simple programming language specifically crafted for creating highly scalable systems that are reliable, efficient, and easy to maintain.
Apache License 2.0
124 stars 11 forks source link

Create an Query Builder for SQL #15

Open unbalancedparentheses opened 10 months ago

unbalancedparentheses commented 10 months ago

We should copy many ideas from Ecto. The thing is that we don't support macros so we need to debate what do we do. Probably add something like comptime.

Ecto really hits the sweet spot.Usually, there are two camps on data accessing:1. Anti-ORM because object-relational impedance mismatch: ORM will always be a leaky abstraction, and it introduces its own learning curve and mental overhead.2. Pro-ORM: despite the impedance mismatch, the alternatives usually suck when it comes to writing: The boilerplate, the ad-hoc-ness. Very often people would use query builders to build yet another leaky abstraction so ORM seems to be the necessary evil.Meanwhile Ecto:1. It's one of the best query builders on the market. Thanks to Elixir macros, it's very flexible and you can just use functions to parameterize and reuse them very easily.2. It's not an ORM but there's also a Schema as a shorthand counterpart for regular things.3. By the way, it doesn't lazy load so n+1 is not a problem anymore. | Ecto really hits the sweet spot.Usually, there are two camps on data accessing:1. Anti-ORM because object-relational impedance mismatch: ORM will always be a leaky abstraction, and it introduces its own learning curve and mental overhead.2. Pro-ORM: despite the impedance mismatch, the alternatives usually suck when it comes to writing: The boilerplate, the ad-hoc-ness. Very often people would use query builders to build yet another leaky abstraction so ORM seems to be the necessary evil.Meanwhile Ecto:1. It's one of the best query builders on the market. Thanks to Elixir macros, it's very flexible and you can just use functions to parameterize and reuse them very easily.2. It's not an ORM but there's also a Schema as a shorthand counterpart for regular things.3. By the way, it doesn't lazy load so n+1 is not a problem anymore.

I would also mention the changesets which are the best way to represent data changes, it's so useful that I use it outside of databases. The main issue for me with ecto is the lack of helpers with mass inserts, thinks like activerecord import & in_batches of activerecord would be nice.