summary refs log tree commit diff stats
path: root/lib/impure/db_odbc.nim
diff options
context:
space:
mode:
authorLeonardo Cecchi <leonardoce@interfree.it>2019-01-07 00:48:55 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-01-07 00:48:55 +0100
commitb7be67349b2677a251aba8fda999a49b7a85af70 (patch)
treede5d873bf826099b2afef04b43e22caaf2a97c01 /lib/impure/db_odbc.nim
parentea3e32c2249ee010eab986850ce52c50fdf4c46e (diff)
downloadNim-b7be67349b2677a251aba8fda999a49b7a85af70.tar.gz
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]
Diffstat (limited to 'lib/impure/db_odbc.nim')
-rw-r--r--lib/impure/db_odbc.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim
index 72d7aa800..b7af5128a 100644
--- a/lib/impure/db_odbc.nim
+++ b/lib/impure/db_odbc.nim
@@ -131,7 +131,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] .} =