diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-09-29 18:16:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-29 12:16:42 +0200 |
commit | f56085f21e60437135eb8ff0167d3c819dfdd2fc (patch) | |
tree | c1747361286f4fe8f374a200935df7dbdba7fd2a /lib/impure/db_odbc.nim | |
parent | 77a65d3c33f408e1c40c4a99e469cded376719e8 (diff) | |
download | Nim-f56085f21e60437135eb8ff0167d3c819dfdd2fc.tar.gz |
refactor dbFormat (#19746)
* refactor dbFormat * add simple tests
Diffstat (limited to 'lib/impure/db_odbc.nim')
-rw-r--r-- | lib/impure/db_odbc.nim | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim index da1b1e9b5..756957acb 100644 --- a/lib/impure/db_odbc.nim +++ b/lib/impure/db_odbc.nim @@ -92,7 +92,7 @@ import strutils, odbcsql import db_common export db_common -import std/private/since +import std/private/[since, dbutils] type OdbcConnTyp = tuple[hDb: SqlHDBC, env: SqlHEnv, stmt: SqlHStmt] @@ -197,14 +197,7 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string {. noSideEffect.} = ## Replace any `?` placeholders with `args`, ## and quotes the arguments - result = "" - var a = 0 - for c in items(string(formatstr)): - if c == '?': - add(result, dbQuote(args[a])) - inc(a) - else: - add(result, c) + dbFormatImpl(formatstr, dbQuote, args) proc prepareFetch(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): TSqlSmallInt {. |