From 6a5b9f63793f7efd1d923365cf32bb05a32793b0 Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 25 Oct 2010 17:03:44 -0700 Subject: Adding 'read_only' on the opentable statement, and trying to be slightly smart about nextrow and the BLOB type at least. --- lib/dblib.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/dblib.lua b/lib/dblib.lua index f9130be..8a1f7e1 100644 --- a/lib/dblib.lua +++ b/lib/dblib.lua @@ -227,7 +227,7 @@ END; } end, - opentable = function(db, tablename, ddl, force_create) + opentable = function(db, tablename, ddl, force_create, read_only) local tname if db._.prefix and db._.prefix ~= "" and db._.odbc_name == "oracle" then tname = db._.fq .. db._.prefix .. db._.fq .. '.' .. db._.fq .. db.sql_escape(tablename) .. db._.fq @@ -239,7 +239,7 @@ END; local operations = 0 local dfields = db:Desc(tablename) - if force_create or dfields == nil then + if force_create or dfields == nil and not read_only then -- table doesn't exist, create it local q = "CREATE TABLE " .. tname .. " (" local k, v, first @@ -298,7 +298,7 @@ END; db:SafeQuery("DROP TABLE " .. tname .. ";", "update") end end - else + else not read_only -- table exists, let's check it. local i local any_common = false @@ -780,7 +780,12 @@ END; if t._.db._.rset:next() ~= 0 then row = {} for k, v in pairs(t._.db._.fieldsNames) do - row[v] = t._.db._.rset:getString(k) + local ftype = get_canon_type(t._.ddl[v] and t._.ddl[v].type or "varchar", v, t._.db) + if ftype == "BLOB" + row[v] = t._.db._.rset:getBlob(k) + else + row[v] = t._.db._.rset:getString(k) + end end end return row -- cgit v1.2.3