You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the nim discord ajusa previously encountered this issue where they had a database, but one of the columns they had was called group.
This causes issues with sqlite's SQL (and likely postgres but I didn't test that). In the language you can avoid those by escaping the name with '.
So minimal reproducible example:
import norm/[model, sqlite]
type A =refobjectofModel
group: stringlet x =A(group: "")
let con =open(":memory:", "", "", "")
con.createTables(x)
Error: unhandled exception: near "group": syntax error [DbError]
The SQL generated is
CREATETABLEIF NOT EXISTS "A"(group TEXTNOT NULL, id INTEGERNOT NULLPRIMARY KEY)
To fix this, the SQL it would need to generate would be this (can also use " instead of '):
CREATETABLEIF NOT EXISTS "A"('group'TEXTNOT NULL, id INTEGERNOT NULLPRIMARY KEY)
A similar issue goes for selectAll as it generates for example this sql:
import norm/[model, sqlite]
type A*=refobjectofModel
group*: stringlet con =open(":memory:", "", "", "")
let y ="""CREATE TABLE IF NOT EXISTS "A"('group' TEXT NOT NULL, id INTEGER NOT NULL PRIMARY KEY)"""
con.exec(sql y)
var objs =@[A(group: "")]
con.selectAll(objs)
SELECT"A".group, "A".id FROM"A"WHERE1
Should be generating
SELECT"A"."group", "A"."id"FROM"A"WHERE1
The text was updated successfully, but these errors were encountered:
In the nim discord ajusa previously encountered this issue where they had a database, but one of the columns they had was called
group
.This causes issues with sqlite's SQL (and likely postgres but I didn't test that). In the language you can avoid those by escaping the name with
'
.So minimal reproducible example:
The SQL generated is
To fix this, the SQL it would need to generate would be this (can also use
"
instead of'
):A similar issue goes for
selectAll
as it generates for example this sql:Should be generating
The text was updated successfully, but these errors were encountered: