feat: handle bool option conversion

This commit is contained in:
emizzle 2020-11-23 16:51:05 +11:00 committed by Michael Bradley
parent 26d2d06b12
commit a8cd7c5c57
1 changed files with 3 additions and 1 deletions

View File

@ -145,7 +145,9 @@ proc fromDbValue*(val: DbValue, T: typedesc[seq[byte]]): seq[byte] = val.blobVal
proc fromDbValue*(val: DbValue, T: typedesc[DbValue]): T = val
proc fromDbValue*[T](val: DbValue, _: typedesc[Option[T]]): Option[T] =
if val.kind == sqliteNull:
if (val.kind == sqliteNull) or
(val.kind == sqliteText and val.strVal == "") or
(val.kind == sqliteInteger and val.intVal == 0):
none(T)
else:
some(val.fromDbValue(T))