parent
77a65d3c33
commit
f56085f21e
1 changed files with 34 additions and 34 deletions
|
|
@ -88,7 +88,7 @@ import strutils, postgres
|
|||
import db_common
|
||||
export db_common
|
||||
|
||||
import std/private/since
|
||||
import std/private/[since, dbutils]
|
||||
|
||||
type
|
||||
DbConn* = PPGconn ## encapsulates a database connection
|
||||
|
|
@ -116,19 +116,7 @@ proc dbQuote*(s: string): string =
|
|||
add(result, '\'')
|
||||
|
||||
proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string =
|
||||
result = ""
|
||||
var a = 0
|
||||
if args.len > 0 and not string(formatstr).contains("?"):
|
||||
dbError("""parameter substitution expects "?" """)
|
||||
if args.len == 0:
|
||||
return string(formatstr)
|
||||
else:
|
||||
for c in items(string(formatstr)):
|
||||
if c == '?':
|
||||
add(result, dbQuote(args[a]))
|
||||
inc(a)
|
||||
else:
|
||||
add(result, c)
|
||||
dbFormatImpl(formatstr, dbQuote, args)
|
||||
|
||||
proc tryExec*(db: DbConn, query: SqlQuery,
|
||||
args: varargs[string, `$`]): bool {.tags: [ReadDbEffect, WriteDbEffect].} =
|
||||
|
|
|
|||
Loading…
Reference in a new issue