summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2015-09-19 18:36:43 +0000
committerTed Trask <ttrask01@yahoo.com>2015-09-19 18:36:43 +0000
commitae60921079fc349d0aab112c8536c33375001393 (patch)
tree38e10ba2780b9153b709d30f65f76f58b4e5ca22
parent76e4acf10743c99474f9a35856ad164975a8d4ac (diff)
downloadacf-db-ae60921079fc349d0aab112c8536c33375001393.tar.bz2
acf-db-ae60921079fc349d0aab112c8536c33375001393.tar.xz
Use db.getcolumndata to determine column type as previous version did not work for sqlite
-rw-r--r--lib/dbmodelfunctions.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/dbmodelfunctions.lua b/lib/dbmodelfunctions.lua
index d333548..e79bcb0 100644
--- a/lib/dbmodelfunctions.lua
+++ b/lib/dbmodelfunctions.lua
@@ -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] = c.name
+ if c.key then
+ retval.value.keyfields.value[#retval.value.keyfields.value+1] = c.name
+ end
+ fieldtypes[c.name] = c.type
+ end
local orderby = {}
local columns = {}