Commit ca008912 authored by Ted Trask's avatar Ted Trask

Modified validation to convert to default timestamp format.

parent 388baf2f
......@@ -501,6 +501,33 @@ local testdatabaseentry = function(datatype, value)
return success, errtxt
end
local convertdatabaseentry = function(datatype, value)
local success = true
local errtxt
local result = value
local res, err = pcall(function()
local sql = "CREATE TEMP TABLE testing ( test "..escape(datatype).." )"
assert (con:execute(sql))
sql = "INSERT INTO testing VALUES ('"..value.."')"
assert (con:execute(sql))
sql = "SELECT * FROM testing"
local cur = assert (con:execute(sql))
local row = cur:fetch ({}, "a")
if row then
result = row.test
end
end)
if not res then
success = false
errtxt = string.gsub(err or "", "\n.*", "")
end
local res, err = pcall(function()
local sql = "DROP TABLE testing"
assert (con:execute(sql))
end)
return success, errtxt, result
end
local printtableentries = function(tablename)
-- retrieve a cursor
local count = 0
......@@ -1009,15 +1036,15 @@ local validateparameters = function(params)
databaseconnect(DatabaseUser)
local s
if params.starttime.value ~= "" then
s,params.starttime.errtxt = testdatabaseentry("TIMESTAMP", params.starttime.value)
s,params.starttime.errtxt,params.starttime.value = convertdatabaseentry("TIMESTAMP", params.starttime.value)
success = success and s
end
if params.endtime.value ~= "" then
s,params.endtime.errtxt = testdatabaseentry("TIMESTAMP", params.endtime.value)
s,params.endtime.errtxt,params.endtime.value = convertdatabaseentry("TIMESTAMP", params.endtime.value)
success = success and s
end
if params.focus.value ~= "" then
s,params.focus.errtxt = testdatabaseentry("TIMESTAMP", params.focus.value)
s,params.focus.errtxt,params.focus.value = convertdatabaseentry("TIMESTAMP", params.focus.value)
success = success and s
end
databasedisconnect()
......@@ -1163,11 +1190,11 @@ local function validateconfig(newconfig)
databaseconnect(DatabaseUser)
local s
if newconfig.value.auditstart.value ~= "" then
s,newconfig.value.auditstart.errtxt = testdatabaseentry("TIMESTAMP", newconfig.value.auditstart.value)
s,newconfig.value.auditstart.errtxt,newconfig.value.auditstart.value = convertdatabaseentry("TIMESTAMP", newconfig.value.auditstart.value)
success = success and s
end
if newconfig.value.auditend.value ~= "" then
s,newconfig.value.auditend.errtxt = testdatabaseentry("TIMESTAMP", newconfig.value.auditend.value)
s,newconfig.value.auditend.errtxt,newconfig.value.auditend.value = convertdatabaseentry("TIMESTAMP", newconfig.value.auditend.value)
success = success and s
end
databasedisconnect()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment