I think that query builders are nice to have and proofs of concept are
simple for simple queries, but the moment you need to leave the simple
query domain and do something a little more complicated, things start to
fall apart. As an example, say you want to store a struct in a database
which contains an array field. In Postgres, you could create an array
column, while in mssql, you would need a 1NF schema with a separate table
for that column, and then you'd associate that column table with the struct
table via primary key or something. The query structure in both these cases
is drastically different. Other complications, which come up all the time -
basic JOINS, window functions, calling sql functions.

ANSI SQL is, unfortunately, a very small subset of the SQL out in the wild,
and every DB extends it in some way - I've found that to be a major
challenge to deal with. For example, you have that "Returning" option.
That'll only work on some DB's (postgres comes to mind) since it's not in
the ANSI SQL spec.

-- Marcin

On Sat, Jul 13, 2019 at 7:41 AM Andrew Pillar <m...@andrewpillar.com> wrote:

> I put together a blog post exploring some of the approaches that could
> be taken for idiomatic query building in Go. The Tl;DR of it is this:
>
> First class functions are an idiomatic way of doing SQL query building
> in Go. Check out the repository containing some example code I wrote
> testing this out: https://github.com/andrewpillar/query.
>
> I'd be interested in hearing what other people have to say with regards
> to this subject matter.
>
>
> https://andrewpillar.com/programming/2019/07/13/orms-and-query-building-in-go/
>
> --
> Andrew
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/8b47ed4c0cc1b5bccea6147878ad9e515909c8e7.camel%40andrewpillar.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29Lt14iz3mRcscsOewcFO2J9zvspBsgKfsArXvgjyRfnkdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to