diff options
author | Badlop <badlop@process-one.net> | 2021-05-10 11:37:59 +0200 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2021-05-10 12:04:52 +0200 |
commit | 916653e2347facfc10d5e32dd21254733bb7271e (patch) | |
tree | a63ea08906a67dcc6e62ce841712581ab44776ce /src/mod_privacy_sql.erl | |
parent | Document that sql_ssl can be used with MySQL too (diff) |
Cast as boolean when exporting privacy_list_data to PostgreSQL (#1773)
Diffstat (limited to 'src/mod_privacy_sql.erl')
-rw-r--r-- | src/mod_privacy_sql.erl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mod_privacy_sql.erl b/src/mod_privacy_sql.erl index 87dd95510..b27442724 100644 --- a/src/mod_privacy_sql.erl +++ b/src/mod_privacy_sql.erl @@ -185,6 +185,7 @@ remove_lists(LUser, LServer) -> end. export(Server) -> + SqlType = ejabberd_option:sql_type(Server), case catch ejabberd_sql:sql_query(jid:nameprep(Server), [<<"select id from privacy_list order by " "id desc limit 1;">>]) of @@ -223,6 +224,21 @@ export(Server) -> "id=%(ID)d"]), ?SQL("delete from privacy_list_data where" " id=%(ID)d;")] ++ + case SqlType of + pgsql -> + [?SQL("insert into privacy_list_data(id, t, " + "value, action, ord, match_all, match_iq, " + "match_message, match_presence_in, " + "match_presence_out) " + "values (%(ID)d, %(SType)s, %(SValue)s, %(SAction)s," + " %(Order)d, CAST(%(MatchAll)b as boolean), CAST(%(MatchIQ)b as boolean)," + " CAST(%(MatchMessage)b as boolean), CAST(%(MatchPresenceIn)b as boolean)," + " CAST(%(MatchPresenceOut)b as boolean));") + || {SType, SValue, SAction, Order, + MatchAll, MatchIQ, + MatchMessage, MatchPresenceIn, + MatchPresenceOut} <- RItems]; + _ -> [?SQL("insert into privacy_list_data(id, t, " "value, action, ord, match_all, match_iq, " "match_message, match_presence_in, " @@ -235,6 +251,7 @@ export(Server) -> MatchAll, MatchIQ, MatchMessage, MatchPresenceIn, MatchPresenceOut} <- RItems] + end end, Lists); (_Host, _R) -> |