24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-18 22:15:20 +02:00

Merge pull request #273 from gamenet/master

odb_queries patch return value of functions update and update_t in case of sql insert
This commit is contained in:
Evgeny Khramtsov 2014-08-08 16:03:03 +04:00
commit 0917209711
2 changed files with 14 additions and 5 deletions

View File

@ -296,8 +296,9 @@ get_sm_features(Acc, _From, _To, _Node, _Lang) ->
store_packet(From, To, Packet) ->
Type = xml:get_tag_attr_s(<<"type">>, Packet),
BodyElem = xml:get_path_s(Packet,[{elem, <<"body">>}]),
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
and (Type /= <<"headline">>) ->
and (Type /= <<"headline">>) and (<<>> /= BodyElem) ->
case has_no_storage_hint(Packet) of
false ->
case check_event(From, To, Packet) of

View File

@ -97,10 +97,14 @@ update_t(Table, Fields, Vals, Where) ->
of
{updated, 1} -> ok;
_ ->
ejabberd_odbc:sql_query_t([<<"insert into ">>, Table,
Res = ejabberd_odbc:sql_query_t([<<"insert into ">>, Table,
<<"(">>, join(Fields, <<", ">>),
<<") values ('">>, join(Vals, <<"', '">>),
<<"');">>])
<<"');">>]),
case Res of
{updated,1} -> ok;
_ -> Res
end
end.
update(LServer, Table, Fields, Vals, Where) ->
@ -115,10 +119,14 @@ update(LServer, Table, Fields, Vals, Where) ->
of
{updated, 1} -> ok;
_ ->
ejabberd_odbc:sql_query(LServer,
Res = ejabberd_odbc:sql_query(LServer,
[<<"insert into ">>, Table, <<"(">>,
join(Fields, <<", ">>), <<") values ('">>,
join(Vals, <<"', '">>), <<"');">>])
join(Vals, <<"', '">>), <<"');">>]),
case Res of
{updated,1} -> ok;
_ -> Res
end
end.
%% F can be either a fun or a list of queries