mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Don't use REPLACE for upsert when there are "-" fields.
This should fix problem reported in #3476
This commit is contained in:
parent
402b301eb5
commit
446cb485ac
@ -549,6 +549,20 @@ parse_upsert_field1([C | S], Acc, ParamPos, Loc) ->
|
||||
|
||||
make_sql_upsert(Table, ParseRes, Pos) ->
|
||||
check_upsert(ParseRes, Pos),
|
||||
HasInsertOnlyFields = lists:any(
|
||||
fun({_, {false}, _}) -> true;
|
||||
(_) -> false
|
||||
end, ParseRes),
|
||||
MySqlReplace = case HasInsertOnlyFields of
|
||||
false ->
|
||||
[erl_syntax:clause(
|
||||
[erl_syntax:atom(mysql), erl_syntax:underscore()],
|
||||
[],
|
||||
[make_sql_upsert_mysql(Table, ParseRes),
|
||||
erl_syntax:atom(ok)])];
|
||||
_ ->
|
||||
[]
|
||||
end,
|
||||
erl_syntax:fun_expr(
|
||||
[erl_syntax:clause(
|
||||
[erl_syntax:atom(pgsql), erl_syntax:variable("__Version")],
|
||||
@ -557,13 +571,9 @@ make_sql_upsert(Table, ParseRes, Pos) ->
|
||||
erl_syntax:operator('>='),
|
||||
erl_syntax:integer(90100))],
|
||||
[make_sql_upsert_pgsql901(Table, ParseRes),
|
||||
erl_syntax:atom(ok)]),
|
||||
erl_syntax:clause(
|
||||
[erl_syntax:atom(mysql), erl_syntax:underscore()],
|
||||
[],
|
||||
[make_sql_upsert_mysql(Table, ParseRes),
|
||||
erl_syntax:atom(ok)]),
|
||||
erl_syntax:clause(
|
||||
erl_syntax:atom(ok)])] ++
|
||||
MySqlReplace ++
|
||||
[erl_syntax:clause(
|
||||
[erl_syntax:underscore(), erl_syntax:underscore()],
|
||||
none,
|
||||
[make_sql_upsert_generic(Table, ParseRes)])
|
||||
|
Loading…
Reference in New Issue
Block a user