@mikra: Now I get it. That could be a solution, but I would prefer that it
would handled by the lib db_postgres.
@timothee: I can't seem to figure out, how to let `proc insertID*` accept it as
`Option[string]` and still use `nil`.. :(
**Current solution**
# lib/impure/db_postgres.nim
proc dbFormat(formatstr: SqlQuery, args: varargs[string], emptyIsNull =
true): string =
# emptyIsNull = true => Empty strings, "", will be set to NULL
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 == '?':
# Check for emptyIsNull and empty string
if emptyIsNull and args[a].len() == 0:
add(result, "NULL")
else:
add(result, dbQuote(args[a]))
inc(a)
else:
add(result, c)
Run