diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-11-16 17:22:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-16 10:22:51 +0100 |
commit | 06cd15663d6aed6cbf03a265f546043c47f250d4 (patch) | |
tree | 644bcc378c2a044655df58a91058b7c73e478d06 /lib/impure | |
parent | 3d692d08f74e41588fa157b006e882f142bd77d4 (diff) | |
download | Nim-06cd15663d6aed6cbf03a265f546043c47f250d4.tar.gz |
fixes ptr to cstring warnings[backport] (#20848)
* fix =#13790 ptr char (+friends) should not implicitly convert to cstring * Apply suggestions from code review * first round; compiles on windows * nimPreviewSlimSystem * conversion is unsafe, cast needed * fixes more tests * fixes asyncnet * another try another error * last one * true * one more * why bugs didn't show at once * add `nimPreviewCstringConversion` switch * typo * fixes ptr to cstring warnings[backport] * add fixes Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
Diffstat (limited to 'lib/impure')
-rw-r--r-- | lib/impure/db_odbc.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim index 2427f64fa..62f047b49 100644 --- a/lib/impure/db_odbc.nim +++ b/lib/impure/db_odbc.nim @@ -137,7 +137,7 @@ proc getErrInfo(db: var DbConn): tuple[res: int, ss, ne, msg: string] {. 511.TSqlSmallInt, retSz.addr) except: discard - return (res.int, $(addr sqlState), $(addr nativeErr), $(addr errMsg)) + return (res.int, $(cast[cstring](addr sqlState)), $cast[cstring](addr nativeErr), $cast[cstring](addr errMsg)) proc dbError*(db: var DbConn) {. tags: [ReadDbEffect, WriteDbEffect], raises: [DbError] .} = @@ -187,7 +187,7 @@ proc sqlGetDBMS(db: var DbConn): string {. db.sqlCheck(SQLGetInfo(db.hDb, SQL_DBMS_NAME, cast[SqlPointer](buf.addr), 4095.TSqlSmallInt, sz.addr)) except: discard - return $(addr buf) + return $(cast[cstring](addr buf)) proc dbQuote*(s: string): string {.noSideEffect.} = ## DB quotes the string. @@ -291,7 +291,7 @@ iterator fastRows*(db: var DbConn, query: SqlQuery, buf[0] = '\0' db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR, cast[cstring](buf.addr), 4095, sz.addr)) - rowRes[colId-1] = $(addr buf) + rowRes[colId-1] = $cast[cstring]((addr buf)) yield rowRes res = SQLFetch(db.stmt) properFreeResult(SQL_HANDLE_STMT, db.stmt) @@ -319,7 +319,7 @@ iterator instantRows*(db: var DbConn, query: SqlQuery, buf[0] = '\0' db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR, cast[cstring](buf.addr), 4095, sz.addr)) - rowRes[colId-1] = $(addr buf) + rowRes[colId-1] = $cast[cstring](addr buf) yield (row: rowRes, len: cCnt.int) res = SQLFetch(db.stmt) properFreeResult(SQL_HANDLE_STMT, db.stmt) @@ -358,7 +358,7 @@ proc getRow*(db: var DbConn, query: SqlQuery, buf[0] = '\0' db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR, cast[cstring](buf.addr), 4095, sz.addr)) - rowRes[colId-1] = $(addr buf) + rowRes[colId-1] = $cast[cstring](addr buf) res = SQLFetch(db.stmt) result = rowRes properFreeResult(SQL_HANDLE_STMT, db.stmt) @@ -386,7 +386,7 @@ proc getAllRows*(db: var DbConn, query: SqlQuery, buf[0] = '\0' db.sqlCheck(SQLGetData(db.stmt, colId.SqlUSmallInt, SQL_C_CHAR, cast[cstring](buf.addr), 4095, sz.addr)) - rowRes[colId-1] = $(addr buf) + rowRes[colId-1] = $cast[cstring](addr buf) rows.add(rowRes) res = SQLFetch(db.stmt) result = rows |