diff options
author | Thomas Johnson <tbjohnson123@gmail.com> | 2017-10-24 01:48:45 -0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-24 10:48:45 +0200 |
commit | 61a50d9c8c46d80fe947a5f86fb30ee8ca922976 (patch) | |
tree | 2751b61e8a7e27de36aa4a7a32d6ab0721af2cda /lib | |
parent | ce04288d6492c36f5021198d9d7fe8a6932959e4 (diff) | |
download | Nim-61a50d9c8c46d80fe947a5f86fb30ee8ca922976.tar.gz |
Fixes #6571 (#6578)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/impure/db_postgres.nim | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index a42950557..b0d3170f8 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -98,15 +98,18 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string = var a = 0 if args.len > 0 and not string(formatstr).contains("?"): dbError("""parameter substitution expects "?" """) - for c in items(string(formatstr)): - if c == '?': - if args[a] == nil: - add(result, "NULL") + if args.len == 0: + return string(formatstr) + else: + for c in items(string(formatstr)): + if c == '?': + if args[a] == nil: + add(result, "NULL") + else: + add(result, dbQuote(args[a])) + inc(a) else: - add(result, dbQuote(args[a])) - inc(a) - else: - add(result, c) + add(result, c) proc tryExec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {.tags: [ReadDbEffect, WriteDbEffect].} = |