Skip to content

Commit

Permalink
refactor dbFormat (#19746)
Browse files Browse the repository at this point in the history
* refactor dbFormat

* add simple tests
  • Loading branch information
ringabout committed Sep 29, 2022
1 parent 344d861 commit 769869c
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/db_odbc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 {.
Expand Down

0 comments on commit 769869c

Please sign in to comment.