PostgREST / PostgREST/postgrest
Feature request: empty SELECT lists
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 27.7k
- Forks
- 1.2k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 54
Description
Once again, thank you very much for your time
Summary
I believe that I'm in need of Empty SELECT Lists
Based on my readings, with regards to "is this possible?" we're in luck (in regards to postgresql support). See docs here:
Empty SELECT Lists
The list of output expressions after SELECT can be empty, producing a zero-column result table. This is not valid syntax according to the SQL standard. PostgreSQL allows it to be consistent with allowing zero-column tables. However, an empty list is not allowed when DISTINCT is used.
Now, whether or not we want to support this is what I'm here to discuss.
As it currently stands, in the case where we want to update/delete only a single row, we need to use "return=representation" in order to get the safety of only updating (or deleting) said row. There is 1 downside and 1 edge case/issue of using "return=representation" in this situation:
-
downside: update/delete one always returns data, even if you don't explictly select. Luckily, in most cases, I imagine that this is not a huge issue.
-
edge case: if the table has any write only fields, the update/delete will fail; this is because of the default behavior of postgrest to
select *.
Workaround
The current solution/workaround for the above "edge case" is to explicitly add a select for any of the readable fields.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the PostgreSQL empty SELECT lists documentation and the issue's return=representation workaround first. Define how empty selections should affect single-row update/delete requests, including tables with write-only fields; done means those operations work without returning unreadable columns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, postgresql
- Domain
- api, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100