Undo broken type gen, verify type at compile time

This commit is contained in:
Zed
2019-08-18 01:26:38 +02:00
parent 16f77223ff
commit 520bafc617
3 changed files with 21 additions and 18 deletions

View File

@@ -1,9 +1,20 @@
import strutils
import sequtils, macros
import types
import prefs_impl
export genUpdatePrefs
static:
var pFields: seq[string]
for id in getTypeImpl(Prefs)[2]:
if $id[0] == "id": continue
pFields.add $id[0]
let pDefs = toSeq(allPrefs()).mapIt(it.name)
let missing = pDefs.filterIt(it notin pFields)
if missing.len > 0:
raiseAssert("{$1} missing from the Prefs type" % missing.join(", "))
withCustomDb("prefs.db", "", "", ""):
try:
createTables()