]> granicus.if.org Git - ejabberd/commitdiff
Fix PostgreSQL compatibility in mod_offline_sql:remove_old_messages (#2695)
authorAlexey Shchepin <alexey@process-one.net>
Tue, 4 Dec 2018 22:56:39 +0000 (01:56 +0300)
committerAlexey Shchepin <alexey@process-one.net>
Tue, 4 Dec 2018 22:56:39 +0000 (01:56 +0300)
src/mod_offline_sql.erl

index c114b1dce7a9c4b6887dbfab19bdddd7ecc12104..f2cc682d6601830bf03464bec697068ad07f443e 100644 (file)
@@ -90,8 +90,17 @@ remove_expired_messages(_LServer) ->
 remove_old_messages(Days, LServer) ->
     case ejabberd_sql:sql_query(
           LServer,
-          ?SQL("DELETE FROM spool"
-                " WHERE created_at < NOW() - INTERVAL %(Days)d DAY")) of
+           fun(pgsql, _) ->
+                   ejabberd_sql:sql_query_t(
+                     ?SQL("DELETE FROM spool"
+                          " WHERE created_at <"
+                          " NOW() - INTERVAL '%(Days)d DAY'"));
+              (_, _) ->
+                   ejabberd_sql:sql_query_t(
+                     ?SQL("DELETE FROM spool"
+                          " WHERE created_at < NOW() - INTERVAL %(Days)d DAY"))
+              end)
+        of
        {updated, N} ->
            ?INFO_MSG("~p message(s) deleted from offline spool", [N]);
        _Error ->