mod_storage_sql2: Build counter query without ORDER BY clause
authorKim Alvefur <zash@zash.se>
Tue, 8 Apr 2014 17:23:11 +0000 (19:23 +0200)
committerKim Alvefur <zash@zash.se>
Tue, 8 Apr 2014 17:23:11 +0000 (19:23 +0200)
plugins/mod_storage_sql2.lua

index 7a2ec4a76e9fa307eec850adab21ee921f35220b..7414e5ed155ad256a24b4bb755062b189b9bc0ba 100644 (file)
@@ -289,7 +289,7 @@ function archive_store:find(username, query)
 
                -- Total matching
                if query.total then
-                       local stats = engine:select(sql_query:gsub("^(SELECT).-(FROM)", "%1 COUNT(*) %2"):format(t_concat(where, " AND "), "DESC", ""), unpack(args));
+                       local stats = engine:select("SELECT COUNT(*) FROM `prosodyarchive` WHERE " .. t_concat(where, " AND "), unpack(args));
                        if stats then
                                local _total = stats()
                                total = _total and _total[1];