diff options
author | flywind <xzsflywind@gmail.com> | 2021-08-13 00:21:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 09:21:01 -0700 |
commit | f559319a682fb2abbf2945fd3390585a54f044d5 (patch) | |
tree | c891e6bda03e8ab20e972ec2700b3d3868d7b947 /lib/std | |
parent | 5c1304a4181596e764b05679cd8a0044ab3398dd (diff) | |
download | Nim-f559319a682fb2abbf2945fd3390585a54f044d5.tar.gz |
fix a sqlite bug (#18669)
Diffstat (limited to 'lib/std')
-rw-r--r-- | lib/std/private/dbutils.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/std/private/dbutils.nim b/lib/std/private/dbutils.nim new file mode 100644 index 000000000..0ae3b3702 --- /dev/null +++ b/lib/std/private/dbutils.nim @@ -0,0 +1,15 @@ +import db_common + + +template dbFormatImpl*(formatstr: SqlQuery, dbQuote: proc (s: string): string, args: varargs[string]): string = + var res = "" + var a = 0 + for c in items(string(formatstr)): + if c == '?': + if a == args.len: + dbError("""The number of "?" given exceeds the number of parameters present in the query.""") + add(res, dbQuote(args[a])) + inc(a) + else: + add(res, c) + res |