3 ms·
It seems as if the idea behind this proposal is to help out database folks. If so, that is misguided. POST is a better implementation than QUERY (or GET) at lea
by hodgesrm 5y ago
It seems as if the idea behind this proposal is to help out database folks. If so, that is misguided. POST is a better implementation than QUERY (or GET) at least for SQL databases. Here's why.
In SQL this is a query:
SELECT a, b, c FROM foo LIMIT 1
But this is also a "query" in many if not most connectivity APIs.
INSERT INTO foo VALUES (1, 2, 3)
Most client libraries don't know and don't care about the content of the query. It's the database's job to parse it and and do the right thing. The different between the above queries is that the first one returns a result set and the second returns an update count. Here's a simple example using Python and the clickhouse-driver library.
# An UPDATE to the database
client.execute('INSERT INTO iris SELECT * FROM another_iris_table')
# A harmless "query"
result = client.execute('SELECT COUNT(*) FROM iris')
print(result)
For this to work you need to use something underneath that is generic and works regardless of output. POST does this already. The clickhouse-driver does not use HTTP protocol though other ClickHouse drivers do. I'm just using it as example of why you need a protocol than can handle any type of SQL "query" the same way on the wire. Otherwise the client will have to have a SQL parser to figure out which one to use. (Some clients actually do that but they are a very small minority.)
- deleted 5y ago[deleted]
- brightstep 5y agoThe examples in section 4 are just that, examples. They are not intended to be the only format a query may take. The issue with POST that QUERY solves is lack of an idempotency constraint.
- wojcikstefan 5y agoIMO this helps a lot more people than just database folks. Any web application which implements a fairly granular search/filtering mechanism for its resources may run into the URL character limit with GETs. QUERY sounds much more appropriate here than what most applications do today (i.e. abuse POSTs).
- hodgesrm 5y agoIn that case it's not helpful to tie it to SQL. As my examples demonstrated, it's pretty useless for SQL database connectivity. If you are looking a general query mechanism it would make more sense to have something that looks like GET with a body. ClickHouse also supports GET as a verb. In addition to URL length issues the query needs to be URL-encoded which makes it difficult to read and debug. p.s., It's interesting to see my post downvoted. It's more productive to show why it's wrong. I've worked on DBMS connectivity for over 30 years.
- kevincox 5y agoThis isn't tied to SQL. See https://www.ietf.org/archive/id/draft-ietf-httpbis-safe-method-w-body-02.html#name-examples https://www.ietf.org/archive/id/draft-ietf-httpbis-safe-meth... > The non-normative examples in this section make use of a simple, hypothetical plain-text based query syntax based on SQL with results returned as comma-separated values. This is done for illustration purposes only. Implementations are free to use any format they wish on both the request and response.