]> granicus.if.org Git - ejabberd/commitdiff
correct handling of SQL boolean types (EJAB-1275)
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Wed, 14 Jul 2010 11:23:21 +0000 (21:23 +1000)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Wed, 14 Jul 2010 11:23:21 +0000 (21:23 +1000)
src/mod_privacy_odbc.erl
src/odbc/ejabberd_odbc.erl

index ae572ae648a9eddf6ceda958a1ae298f6ea29698..5ad2fb9587f2c7904e3fdbd3218597c75dc43f36 100644 (file)
@@ -726,11 +726,11 @@ raw_to_item({SType, SValue, SAction, SOrder, SMatchAll, SMatchIQ,
            "d" -> deny
        end,
     Order = list_to_integer(SOrder),
-    MatchAll = SMatchAll == "1" orelse SMatchAll == "t",
-    MatchIQ = SMatchIQ == "1" orelse SMatchIQ == "t" ,
-    MatchMessage =  SMatchMessage == "1" orelse SMatchMessage == "t",
-    MatchPresenceIn =  SMatchPresenceIn == "1" orelse SMatchPresenceIn == "t",
-    MatchPresenceOut =  SMatchPresenceOut == "1" orelse SMatchPresenceOut == "t",
+    MatchAll = ejabberd_odbc:to_bool(SMatchAll),
+    MatchIQ = ejabberd_odbc:to_bool(SMatchIQ),
+    MatchMessage = ejabberd_odbc:to_bool(SMatchMessage),
+    MatchPresenceIn = ejabberd_odbc:to_bool(SMatchPresenceIn),
+    MatchPresenceOut =  ejabberd_odbc:to_bool(SMatchPresenceOut),
     #listitem{type = Type,
              value = Value,
              action = Action,
index 1b07fd6d9e0a838e182ed6d4b564671d9c0b0e53..4a6481525638e57542ddc5dadb9fc1de6b90013e 100644 (file)
@@ -39,6 +39,7 @@
         sql_bloc/2,
         escape/1,
         escape_like/1,
+        to_bool/1,
         keep_alive/1]).
 
 %% gen_fsm callbacks
@@ -161,6 +162,12 @@ escape_like($%) -> "\\%";
 escape_like($_) -> "\\_";
 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