News for hackers. Stuff that matters.
Re:PostgREST – Serve a RESTful API from Any Postgres Database by aljarry on Thursday December 29, 2022 @02:28PM (#34176778)
Why not just accept SQL? It's a matter of contract. With REST APIs you specify a contract, it gets robust with time, and other software can expect only what's in the contract. SQL allows you to run arbitrary functions over data in the database, so the whole schema and parts of the content in a way become your contract - and your options to modify the schema (or how you use the database) get very constrained.
Re:PostgREST – Serve a RESTful API from Any Postgres Database by dragonwriter on Thursday December 29, 2022 @02:30PM (#34176810)
You can limit the visible schema, and thus the contract, per role with SQL.
Re:PostgREST – Serve a RESTful API from Any Postgres Database by aljarry on Friday December 30, 2022 @07:22AM (#34184371)
That's a very good point!
Re:PostgREST – Serve a RESTful API from Any Postgres Database by officialchicken on Thursday December 29, 2022 @02:44PM (#34176977)
>Why not just accept SQL?

Sanitize your inputs. I'll let little bobby tables link to the XKCD

Re:PostgREST – Serve a RESTful API from Any Postgres Database by jmull on Thursday December 29, 2022 @04:12PM (#34177999)
Who says don't sanitize inputs?

I'm just suggesting to not invent another query language, especially where a rather obvious and natural one already exists. You can and should sanitize untrusted input regardless.

Re:PostgREST – Serve a RESTful API from Any Postgres Database by lelanthran on Thursday December 29, 2022 @04:42PM (#34178405)
Yeah, but this particular contract/API is pretty much "run arbitrary select/insert/update/delete statements" anyway!

If you're using the postgrest language your options to stabilise the interface are minimal anyway, so why not just go with SQL and a whitelist?

Re:PostgREST – Serve a RESTful API from Any Postgres Database by aljarry on Friday December 30, 2022 @07:21AM (#34184368)
Yes, but the REST vs SQL forces a specific API for changes. REST - update/delete a specific record. SQL - update/delete based on a filter, or a query result. I can do `set a = b` for all rows in the table, which may be needed internally, but it's a pretty bad external interface.