Allow AND/OR in WHERE clause of safe_upsert (+ useless spaces deleted)#722
Allow AND/OR in WHERE clause of safe_upsert (+ useless spaces deleted)#722NicolasGraph wants to merge 1 commit intotextpattern:masterfrom NicolasGraph:master
Conversation
|
I sometimes do this in plugins, where the queries are under control. But for the core usage the regex pattern looks a bit fragile: If you find a more robust pattern, I'll be all for it. |
|
How about that? |
|
That's better, but still will not work with |
|
An easier way would be to pass an array of clauses as |
|
Yes, why not; otherwise |
|
Edit: better here. …but |
|
Still broken for |
|
This is funny to do but I'm not sure if it makes sense to continue… |
|
You'd call it like this: If this is ok, I can submit a (backwards compatible) patch. |
|
Perhaps even this, so it's not even possible to use any operator other than '=' in the where part: |
|
Perhaps, but since we need to insure the bwc, it would be inconsistent with former |
|
How about the operator? It would always be |
|
Only |
|
For me, this kind of thing (customized for clarity): would assign my_data to the column name and en-gb to lang. …? |
|
Bump? Is this targeted for 4.6? |
Not really, I think. It would make plugins authors life a little more convenient, but we (well, I) don't see a natural way to satisfy all the requirement. The best I can do now is follow Ruud's proposal and treat only |
|
I agree, let see if we can find something better for 4.7, pending that plugin authors can build a custom function. I can close this pull request and open an issue…? |
|
I just tripped over this one too (also in combination with setting the language). Has there been a solution to this, or does one have to do this in two stages:
|
|
It should work with |
|
Thanks Oleg. That did it! |
As said here, the following code does not work.
The problem is that on
INSERT, theWHEREclause is simply added to the set clause and throw that:[SQL: INSERT INTO txp_lang SET name = 'my_data' AND lang = 'en-gb', data = 'My data', event = 'public' ]…It keeps the
AND.I know that all
WHEREclauses won't work withsafe_upsertbut can't we allow the use ofAND(andOR?) like so (or in another better way).ORcould work if the two columns are different.