summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 = {}