aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFranko Franicevich <[email protected]>2012-11-09 17:23:42 +0100
committerHenrik Nord <[email protected]>2012-12-04 10:50:03 +0100
commitc4ea387383744fc34656ca99a21e86d6367885f9 (patch)
treece71c7aac7c7c1567f74957aee9503d825052dea
parent66c6cede2b5039ca05ad57d3da3b76a5b8e9da47 (diff)
downloadotp-c4ea387383744fc34656ca99a21e86d6367885f9.tar.gz
otp-c4ea387383744fc34656ca99a21e86d6367885f9.tar.bz2
otp-c4ea387383744fc34656ca99a21e86d6367885f9.zip
Added test case for new odbc option 'extended_errors'
Test case is in odbc 'connect' suite; and just tries force an error with the extended errors flag both on and off; validating the return types. OTP-10603
-rw-r--r--lib/odbc/test/odbc_connect_SUITE.erl32
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/odbc/test/odbc_connect_SUITE.erl b/lib/odbc/test/odbc_connect_SUITE.erl
index a076c4dfff..7d732f20f7 100644
--- a/lib/odbc/test/odbc_connect_SUITE.erl
+++ b/lib/odbc/test/odbc_connect_SUITE.erl
@@ -51,7 +51,7 @@ all() ->
{group, client_dies}, connect_timeout, timeout,
many_timeouts, timeout_reset, disconnect_on_timeout,
connection_closed, disable_scrollable_cursors,
- return_rows_as_lists, api_missuse];
+ return_rows_as_lists, api_missuse, extended_errors];
Other -> {skip, Other}
end.
@@ -838,3 +838,33 @@ transaction_support_str(mysql) ->
"ENGINE = InnoDB";
transaction_support_str(_) ->
"".
+
+
+%%-------------------------------------------------------------------------
+extended_errors(doc)->
+ ["Test the extended errors connection option: When off; the old behaviour of just an error "
+ "string is returned on error. When on, the error string is replaced by a 3 element tuple "
+ "that also exposes underlying ODBC provider error codes."];
+extended_errors(suite) -> [];
+extended_errors(Config) when is_list(Config)->
+ Table = ?config(tableName, Config),
+ {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
+ {updated, _} = odbc:sql_query(Ref, "create table " ++ Table ++" ( id integer, data varchar(10))"),
+
+ % Error case WITHOUT extended errors on...
+ case odbc:sql_query(Ref, "create table " ++ Table ++" ( id integer, data varchar(10))") of
+ {error, ErrorString} when is_list(ErrorString) -> ok
+ end,
+
+ % Now the test case with extended errors on - This should return a tuple, not a list/string now.
+ % The first element is a string that is the ODBC error string; the 2nd element is a native integer error
+ % code passed from the underlying provider driver. The last is the familiar old error string.
+ % We can't check the actual error code; as each different underlying provider will return
+ % a different value - So we just check the return types at least.
+ {ok, RefExtended} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options() ++ [{extended_errors, on}]),
+ case odbc:sql_query(RefExtended, "create table " ++ Table ++" ( id integer, data varchar(10))") of
+ {error, {ODBCCodeString, NativeCodeNum, ShortErrorString}} when is_list(ODBCCodeString), is_number(NativeCodeNum), is_list(ShortErrorString) -> ok
+ end,
+
+ ok = odbc:disconnect(Ref),
+ ok = odbc:disconnect(RefExtended).