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,25 +549,35 @@ 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")],
|
||||
[erl_syntax:infix_expr(
|
||||
erl_syntax:variable("__Version"),
|
||||
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:underscore(), erl_syntax:underscore()],
|
||||
none,
|
||||
[make_sql_upsert_generic(Table, ParseRes)])
|
||||
]).
|
||||
[erl_syntax:clause(
|
||||
[erl_syntax:atom(pgsql), erl_syntax:variable("__Version")],
|
||||
[erl_syntax:infix_expr(
|
||||
erl_syntax:variable("__Version"),
|
||||
erl_syntax:operator('>='),
|
||||
erl_syntax:integer(90100))],
|
||||
[make_sql_upsert_pgsql901(Table, ParseRes),
|
||||
erl_syntax:atom(ok)])] ++
|
||||
MySqlReplace ++
|
||||
[erl_syntax:clause(
|
||||
[erl_syntax:underscore(), erl_syntax:underscore()],
|
||||
none,
|
||||
[make_sql_upsert_generic(Table, ParseRes)])
|
||||
]).
|
||||
|
||||
make_sql_upsert_generic(Table, ParseRes) ->
|
||||
Update = make_sql_query(make_sql_upsert_update(Table, ParseRes)),
|
||||
|
Loading…
Reference in New Issue
Block a user