-
Environment
Description of issueQuestion: Can DELETE use more complex conditions, especially with tables that have composite primary keys? Let's assume mytable has primary key (id, name). I admit something like DELETE https://postgrest/mytable?(id,name)=eq.(14, 'foo') ... is currently not possible but a feasible workaround is DELETE https://postgrest/mytable?id=eq.14&name=eq.foo But what about DELETE https://postgrest/mytable?(id,name)=not.in.((14, 'foo'), (15, 'bar')) i. e. one wants to delete all rows except those with primary keys (14, 'foo') and (15, 'bar'). As far as I know this is currently not possible with postgrest(?) I suspect it all boils down to having kind of a "PostgreSQL ROW Constructor" equivalent in postgrest? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Ah I figured out I can emulate DELETE https://postgrest/mytable?(id,name)=not.in.((14, 'foo'), (15, 'bar')) by using DELETE https://postgrest/mytable?or=(id.neq.14,name.neq.foo)&or=(id.neq.15,name.neq.bar) |
Beta Was this translation helpful? Give feedback.
-
Does that really work? I'm not sure whether we support multiple filters with the same name ( I*d write that as |
Beta Was this translation helpful? Give feedback.
-
Using the following table (which is simply the cartesian product of [14, 15, 16] with [foo, bar, baz]):
GET https://postgrest/mytable?or=(id.neq.14,name.neq.foo)&or=(id.neq.15,name.neq.bar) ... returns all rows BUT (14,foo) and (15,bar) as I would expect when multiple "or" parameters work, and DELETE https://postgrest/mytable?or=(id.neq.14,name.neq.foo)&or=(id.neq.15,name.neq.bar) ... deletes exactly those rows, leaving only (14,foo) and (15,bar). So I can conclude multiple "or" parameters seem to work, right? That's more readable having "&" infix instead of "and=" prefix. |
Beta Was this translation helpful? Give feedback.
Ah I figured out I can emulate
by using