[feature] add unsafeColumnAt procs, that return unsafe cstring from InstantRow (#11647)
This commit is contained in:
parent
c94647aeca
commit
e5425b5f2f
5 changed files with 24 additions and 1 deletions
|
|
@ -19,8 +19,11 @@
|
||||||
|
|
||||||
- Enable Oid usage in hashtables. (#11472)
|
- Enable Oid usage in hashtables. (#11472)
|
||||||
|
|
||||||
|
- Added `unsafeColumnAt` procs, that return unsafe cstring from InstantRow. (#11647)
|
||||||
|
|
||||||
- Make public `Sha1Digest` and `Sha1State` types and `newSha1State`, `update` and `finalize` procedures from `sha1` module. (#11694)
|
- Make public `Sha1Digest` and `Sha1State` types and `newSha1State`, `update` and `finalize` procedures from `sha1` module. (#11694)
|
||||||
|
|
||||||
|
|
||||||
## Language additions
|
## Language additions
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,10 @@ proc `[]`*(row: InstantRow, col: int): string {.inline.} =
|
||||||
## Returns text for given column of the row.
|
## Returns text for given column of the row.
|
||||||
$row.row[col]
|
$row.row[col]
|
||||||
|
|
||||||
|
proc unsafeColumnAt*(row: InstantRow, index: int): cstring {.inline.} =
|
||||||
|
## Return cstring of given column of the row
|
||||||
|
row.row[index]
|
||||||
|
|
||||||
proc len*(row: InstantRow): int {.inline.} =
|
proc len*(row: InstantRow): int {.inline.} =
|
||||||
## Returns number of columns in the row.
|
## Returns number of columns in the row.
|
||||||
row.len
|
row.len
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,11 @@ iterator instantRows*(db: var DbConn, query: SqlQuery,
|
||||||
|
|
||||||
proc `[]`*(row: InstantRow, col: int): string {.inline.} =
|
proc `[]`*(row: InstantRow, col: int): string {.inline.} =
|
||||||
## Returns text for given column of the row
|
## Returns text for given column of the row
|
||||||
row.row[col]
|
$row.row[col]
|
||||||
|
|
||||||
|
proc unsafeColumnAt*(row: InstantRow, index: int): cstring {.inline.} =
|
||||||
|
## Return cstring of given column of the row
|
||||||
|
row.row[index]
|
||||||
|
|
||||||
proc len*(row: InstantRow): int {.inline.} =
|
proc len*(row: InstantRow): int {.inline.} =
|
||||||
## Returns number of columns in the row
|
## Returns number of columns in the row
|
||||||
|
|
|
||||||
|
|
@ -381,6 +381,10 @@ proc `[]`*(row: InstantRow; col: int): string {.inline.} =
|
||||||
## returns text for given column of the row
|
## returns text for given column of the row
|
||||||
$pqgetvalue(row.res, int32(row.line), int32(col))
|
$pqgetvalue(row.res, int32(row.line), int32(col))
|
||||||
|
|
||||||
|
proc unsafeColumnAt*(row: InstantRow, index: int): cstring {.inline.} =
|
||||||
|
## Return cstring of given column of the row
|
||||||
|
pqgetvalue(row.res, int32(row.line), int32(index))
|
||||||
|
|
||||||
proc len*(row: InstantRow): int {.inline.} =
|
proc len*(row: InstantRow): int {.inline.} =
|
||||||
## returns number of columns in the row
|
## returns number of columns in the row
|
||||||
int(pqNfields(row.res))
|
int(pqNfields(row.res))
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,14 @@ proc `[]`*(row: InstantRow, col: int32): string {.inline.} =
|
||||||
## example code
|
## example code
|
||||||
$column_text(row, col)
|
$column_text(row, col)
|
||||||
|
|
||||||
|
proc unsafeColumnAt*(row: InstantRow, index: int32): cstring {.inline.} =
|
||||||
|
## Returns cstring for given column of the row.
|
||||||
|
##
|
||||||
|
## See also:
|
||||||
|
## * `instantRows iterator <#instantRows.i,DbConn,SqlQuery,varargs[string,]>`_
|
||||||
|
## example code
|
||||||
|
column_text(row, index)
|
||||||
|
|
||||||
proc len*(row: InstantRow): int32 {.inline.} =
|
proc len*(row: InstantRow): int32 {.inline.} =
|
||||||
## Returns number of columns in a row.
|
## Returns number of columns in a row.
|
||||||
##
|
##
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue