News for hackers. Stuff that matters.
Re:The Art of PostgreSQL by majewsky on Wednesday August 21, 2019 @04:53AM (#20755545)
> No more "models", ORMs / query builders, and crunching data in app code. Just build your schema, write plain sql queries, and you're off to the races.

I tend to do it the same way, but how do you deal with the lack of a query builder when you truly need to build a query on the fly? For example, what do you do when implementing a REST endpoint like GET /things where the user can give any number of 10 query parameters to filter the result?

Re:The Art of PostgreSQL by mmckelvy on Thursday August 22, 2019 @12:33AM (#20764656)
For cases like this, I use pl/pgsql functions and dynamic queries. Dynamic queries take extra care and aren't the most pleasant things to write, but they can handle the GET /things with 10 parameters endpoints quite well.
Re:The Art of PostgreSQL by wilmoore on Saturday August 24, 2019 @04:21AM (#20785981)
> what do you do when implementing a REST endpoint like GET /things where the user can give any number of 10 query parameters to filter the result?

https://www.elastic.co/guide/en/elasticsearch/reference/curr...

Re:The Art of PostgreSQL by spiderxxxx on Wednesday August 21, 2019 @06:07PM (#20762397)
You do "or <parameter> IS NULL". It makes the query plan uncacheable or requiring a godly cache, but it's fine for searches.