mod_storage_sql: Strip timestamp precision in queries to fix error (thanks muppeth)
authorKim Alvefur <zash@zash.se>
Wed, 07 Sep 2022 12:27:12 +0200
changeset 12727 4cfd09343947
parent 12726 cd993fd7b60d
child 12729 12ced5db29b2
mod_storage_sql: Strip timestamp precision in queries to fix error (thanks muppeth) Fixes Error in SQL transaction: Error executing statement parameters: ERROR: invalid input syntax for integer This was handled for INSERT in 9524bb7f3944 but not SELECT.
plugins/mod_storage_sql.lua
--- a/plugins/mod_storage_sql.lua	Sun Sep 04 10:01:57 2022 +0100
+++ b/plugins/mod_storage_sql.lua	Wed Sep 07 12:27:12 2022 +0200
@@ -355,12 +355,12 @@
 local function archive_where(query, args, where)
 	-- Time range, inclusive
 	if query.start then
-		args[#args+1] = query.start
+		args[#args+1] = math.floor(query.start);
 		where[#where+1] = "\"when\" >= ?"
 	end
 
 	if query["end"] then
-		args[#args+1] = query["end"];
+		args[#args+1] = math.floor(query["end"]);
 		if query.start then
 			where[#where] = "\"when\" BETWEEN ? AND ?" -- is this inclusive?
 		else