From dd8192fc1d6d9fd3c28bb004ebcd8893ea6f064c Mon Sep 17 00:00:00 2001 From: Leonardo Cecchi Date: Mon, 7 Jan 2019 00:48:55 +0100 Subject: [PATCH] Fix ODBC SQL Error string decoding (#10207) [backport] ODBC Errors were presented to the users as a sequence of characters. I.e.: >test_oracle.exe Error: ['H', 'Y', '0', '0', '0', '\x00', '\x00', ...] test_oracle.nim(15) test_oracle test_oracle.nim(8) test_oracle db_odbc.nim(534) open db_odbc.nim(168) dbError Error: unhandled exception: ODBC Error [DbError] This patch fix the string decoding, creating a real string: >test_oracle.exe Error: HY000 [Oracle][ODBC][Ora]ORA-12541: TNS:no listener test_oracle.nim(15) test_oracle test_oracle.nim(8) test_oracle db_odbc.nim(534) open db_odbc.nim(168) dbError Error: unhandled exception: ODBC Error [DbError] (cherry picked from commit b7be67349b2677a251aba8fda999a49b7a85af70) --- lib/impure/db_odbc.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim index 224bcbb501..c82ee65874 100644 --- a/lib/impure/db_odbc.nim +++ b/lib/impure/db_odbc.nim @@ -133,7 +133,7 @@ proc getErrInfo(db: var DbConn): tuple[res: int, ss, ne, msg: string] {. 511.TSqlSmallInt, retSz.addr.PSQLSMALLINT) except: discard - return (res.int, $sqlState, $nativeErr, $errMsg) + return (res.int, $(addr sqlState), $(addr nativeErr), $(addr errMsg)) proc dbError*(db: var DbConn) {. tags: [ReadDbEffect, WriteDbEffect], raises: [DbError] .} =