diff options
author | Danil Onishchenko <[email protected]> | 2013-01-25 15:23:54 +0800 |
---|---|---|
committer | Danil Onishchenko <[email protected]> | 2013-01-25 15:23:54 +0800 |
commit | 026d6778fdadce1eac8cdf486b159fa0d6669836 (patch) | |
tree | 5799b3a033256a8c956575378b49c382fd29cd99 | |
parent | 01618e765dc032ae928a2129fb053fbb0f1f1fd4 (diff) | |
download | otp-026d6778fdadce1eac8cdf486b159fa0d6669836.tar.gz otp-026d6778fdadce1eac8cdf486b159fa0d6669836.tar.bz2 otp-026d6778fdadce1eac8cdf486b159fa0d6669836.zip |
Add testcases for odbc:param_query
Add testcases for odbc:param_query/3 and odbc:param_query4 with unparameterized query string and empty parameters list.
-rw-r--r-- | lib/odbc/test/odbc_query_SUITE.erl | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/lib/odbc/test/odbc_query_SUITE.erl b/lib/odbc/test/odbc_query_SUITE.erl index 1852678b4b..61253b29aa 100644 --- a/lib/odbc/test/odbc_query_SUITE.erl +++ b/lib/odbc/test/odbc_query_SUITE.erl @@ -63,7 +63,8 @@ groups() -> param_insert_numeric, {group, param_insert_string}, param_insert_float, param_insert_real, param_insert_double, param_insert_mix, param_update, - param_delete, param_select]}, + param_delete, param_select, + param_select_empty_params, param_delete_empty_params]}, {param_integers, [], [param_insert_tiny_int, param_insert_small_int, param_insert_int, param_insert_integer]}, @@ -1345,6 +1346,70 @@ param_select(Config) when is_list(Config) -> ok. %%------------------------------------------------------------------------- +param_select_empty_params(doc) -> + ["Test parameterized select query with no parameters."]; +param_select_empty_params(suite) -> + []; +param_select_empty_params(Config) when is_list(Config) -> + Ref = ?config(connection_ref, Config), + Table = ?config(tableName, Config), + + {updated, _} = + odbc:sql_query(Ref, + "CREATE TABLE " ++ Table ++ + " (ID INTEGER, DATA CHARACTER VARYING(10)," + " PRIMARY KEY(ID))"), + + {updated, Count} = odbc:param_query(Ref, "INSERT INTO " ++ Table ++ + "(ID, DATA) VALUES(?, ?)", + [{sql_integer, [1, 2, 3]}, + {{sql_varchar, 10}, + ["foo", "bar", "foo"]}]), + + true = odbc_test_lib:check_row_count(3, Count), + + SelectResult = ?RDBMS:param_select(), + + SelectResult = odbc:param_query(Ref, "SELECT * FROM " ++ Table ++ + " WHERE DATA = \'foo\'", + []), + ok. + +%%------------------------------------------------------------------------- +param_delete_empty_params(doc) -> + ["Test parameterized delete query with no parameters."]; +param_delete_empty_params(suite) -> + []; +param_delete_empty_params(Config) when is_list(Config) -> + Ref = ?config(connection_ref, Config), + Table = ?config(tableName, Config), + + {updated, _} = + odbc:sql_query(Ref, + "CREATE TABLE " ++ Table ++ + " (ID INTEGER, DATA CHARACTER VARYING(10)," + " PRIMARY KEY(ID))"), + + {updated, Count} = odbc:param_query(Ref, "INSERT INTO " ++ Table ++ + "(ID, DATA) VALUES(?, ?)", + [{sql_integer, [1, 2, 3]}, + {{sql_varchar, 10}, + ["foo", "bar", "baz"]}]), + true = odbc_test_lib:check_row_count(3, Count), + + {updated, NewCount} = odbc:param_query(Ref, "DELETE FROM " ++ Table ++ + " WHERE ID = 1 OR ID = 2", + []), + + true = odbc_test_lib:check_row_count(2, NewCount), + + UpdateResult = ?RDBMS:param_delete(), + + UpdateResult = + odbc:sql_query(Ref, "SELECT * FROM " ++ Table), + ok. + +%%------------------------------------------------------------------------- describe_integer(doc) -> ["Test describe_table/[2,3] for integer columns."]; describe_integer(suite) -> |