mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 20:47:53 +00:00
@@ -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].} =
|
||||
|
||||
Reference in New Issue
Block a user