From a861614daf5136b243731b33c8681b7de6d72f9c Mon Sep 17 00:00:00 2001 From: tomas Date: Mon, 23 Jan 2006 20:13:25 +0000 Subject: [PATCH] Adding specific file for ODBC. Adding configuration to some different return values of API functions. --- tests/mysql.lua | 4 +++- tests/odbc.lua | 10 ++++++++++ tests/test.lua | 16 +++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 tests/odbc.lua diff --git a/tests/mysql.lua b/tests/mysql.lua index 7bdc23b..c9c3ffd 100644 --- a/tests/mysql.lua +++ b/tests/mysql.lua @@ -1,8 +1,10 @@ --------------------------------------------------------------------- -- MySQL specific tests and configurations. --- $Id: mysql.lua,v 1.2 2006/01/10 18:34:54 tomas Exp $ +-- $Id: mysql.lua,v 1.3 2006/01/23 20:13:25 tomas Exp $ --------------------------------------------------------------------- +QUERYING_STRING_TYPE_NAME = "binary(65535)" + --------------------------------------------------------------------- -- Build SQL command to create the test table. --------------------------------------------------------------------- diff --git a/tests/odbc.lua b/tests/odbc.lua new file mode 100644 index 0000000..22f9c4a --- /dev/null +++ b/tests/odbc.lua @@ -0,0 +1,10 @@ +--------------------------------------------------------------------- +-- ODBC specific tests and configurations. +-- $Id: odbc.lua,v 1.1 2006/01/23 20:13:25 tomas Exp $ +--------------------------------------------------------------------- + +QUERYING_STRING_TYPE_NAME = "string" +-- The CREATE_TABLE_RETURN_VALUE and DROP_TABLE_RETURN_VALUE works +-- with -1 on MS Acess Driver, and 0 on SQL Server Driver +CREATE_TABLE_RETURN_VALUE = -1 +DROP_TABLE_RETURN_VALUE = -1 diff --git a/tests/test.lua b/tests/test.lua index ede649c..14653f9 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -4,6 +4,12 @@ TOTAL_FIELDS = 40 TOTAL_ROWS = 40 --unused +DEFINITION_STRING_TYPE_NAME = "text" +QUERYING_STRING_TYPE_NAME = "text" + +CREATE_TABLE_RETURN_VALUE = 0 +DROP_TABLE_RETURN_VALUE = 0 + --------------------------------------------------------------------- -- Produces a SQL statement which completely erases a table. -- @param table_name String with the name of the table. @@ -104,7 +110,7 @@ end function define_table (n) local t = {} for i = 1, n do - table.insert (t, "f"..i.." varchar (30)") + table.insert (t, "f"..i.." "..DEFINITION_STRING_TYPE_NAME) end return "create table t ("..table.concat (t, ',')..")" end @@ -118,7 +124,7 @@ function create_table () CONN = CONN_OK (ENV:connect (datasource, username, password)) -- Create t. local cmd = define_table(TOTAL_FIELDS) - assert2 (0, CONN:execute (cmd)) + assert2 (CREATE_TABLE_RETURN_VALUE, CONN:execute (cmd)) end --------------------------------------------------------------------- @@ -423,8 +429,8 @@ function column_info () assert2 (4, table.getn(types), "incorrect column types table") for i = 1, table.getn(names) do assert2 ("f"..i, names[i], "incorrect column names table") - local type_i = string.gsub(types[i], "%s+", "") - assert (type_i == "adVarWChar" or type_i == "varchar(30)" or type_i == "string" or type_i == "string(30)", "incorrect column types table") + local type_i = types[i] + assert (type_i == QUERYING_STRING_TYPE_NAME, "incorrect column types table") end -- check if the tables are being reused. local n2, t2 = cur:getcolnames(), cur:getcoltypes() @@ -478,7 +484,7 @@ end function drop_table () -- Postgres retorna 0, enquanto ODBC retorna -1. CONN:setautocommit(true) - assert2 (0, CONN:execute ("drop table t")) + assert2 (DROP_TABLE_RETURN_VALUE, CONN:execute ("drop table t")) end ---------------------------------------------------------------------