correct handling of SQL boolean types (EJAB-1275)

This commit is contained in:
Evgeniy Khramtsov 2010-07-14 21:23:21 +10:00
parent d7930d7f82
commit 5030f35558
2 changed files with 12 additions and 5 deletions

View File

@ -726,11 +726,11 @@ raw_to_item({SType, SValue, SAction, SOrder, SMatchAll, SMatchIQ,
"d" -> deny "d" -> deny
end, end,
Order = list_to_integer(SOrder), Order = list_to_integer(SOrder),
MatchAll = SMatchAll == "1" orelse SMatchAll == "t", MatchAll = ejabberd_odbc:to_bool(SMatchAll),
MatchIQ = SMatchIQ == "1" orelse SMatchIQ == "t" , MatchIQ = ejabberd_odbc:to_bool(SMatchIQ),
MatchMessage = SMatchMessage == "1" orelse SMatchMessage == "t", MatchMessage = ejabberd_odbc:to_bool(SMatchMessage),
MatchPresenceIn = SMatchPresenceIn == "1" orelse SMatchPresenceIn == "t", MatchPresenceIn = ejabberd_odbc:to_bool(SMatchPresenceIn),
MatchPresenceOut = SMatchPresenceOut == "1" orelse SMatchPresenceOut == "t", MatchPresenceOut = ejabberd_odbc:to_bool(SMatchPresenceOut),
#listitem{type = Type, #listitem{type = Type,
value = Value, value = Value,
action = Action, action = Action,

View File

@ -39,6 +39,7 @@
sql_bloc/2, sql_bloc/2,
escape/1, escape/1,
escape_like/1, escape_like/1,
to_bool/1,
keep_alive/1]). keep_alive/1]).
%% gen_fsm callbacks %% gen_fsm callbacks
@ -161,6 +162,12 @@ escape_like($%) -> "\\%";
escape_like($_) -> "\\_"; escape_like($_) -> "\\_";
escape_like(C) -> odbc_queries:escape(C). escape_like(C) -> odbc_queries:escape(C).
to_bool("t") -> true;
to_bool("true") -> true;
to_bool("1") -> true;
to_bool(true) -> true;
to_bool(1) -> true;
to_bool(_) -> false.
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% Callback functions from gen_fsm %%% Callback functions from gen_fsm