Commit ae609210 authored by Ted Trask's avatar Ted Trask

Use db.getcolumndata to determine column type as previous version did not work for sqlite

parent 76e4acf1
......@@ -126,14 +126,15 @@ function mymodule.list_table_entries(dbase, self, clientdata)
if t == retval.value.table.value then
retval.value.table.errtxt = nil
retval.errtxt = nil
-- FIXME - in the future, we should be able to do next these three things in one function call to db
retval.value.fields.value = db.listcolumns(t) or {}
retval.value.keyfields.value = db.listkeycolumns(t) or {}
-- this will not work for sqlite and the results are database-specific
local sql = "SELECT data_type FROM information_schema.columns WHERE table_name = '"..db.escape(t).."' ORDER BY ordinal_position"
local types = db.getselectresponse(sql)
local fieldtypes = {}
for i,f in ipairs(types) do fieldtypes[retval.value.fields.value[i]] = f.data_type end
local columndata = db.getcolumndata(t)
for i,c in ipairs(columndata) do
retval.value.fields.value[#retval.value.fields.value+1] =
if c.key then
retval.value.keyfields.value[#retval.value.keyfields.value+1] =
fieldtypes[] = c.type
local orderby = {}
local columns = {}
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