diff semiconginev2/thirdparty/db_connector/private/dbutils.nim @ 1218:56781cc0fc7c compiletime-tests

did: renamge main package
author sam <sam@basx.dev>
date Wed, 17 Jul 2024 21:01:37 +0700
parents semicongine/old/thirdparty/db_connector/private/dbutils.nim@239adab121a3
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/semiconginev2/thirdparty/db_connector/private/dbutils.nim	Wed Jul 17 21:01:37 2024 +0700
@@ -0,0 +1,15 @@
+import ../db_common
+
+
+template dbFormatImpl*(formatstr: SqlQuery, dbQuote: proc (s: string): string {.nimcall.}, 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