mirror of
https://github.com/rbock/sqlpp11.git
synced 2025-12-31 10:10:28 -06:00
Treat "PRIMARY KEY" columns as not nullable.
This commit is contained in:
committed by
Roland Bock
parent
3497e5891d
commit
ffd6618e58
@@ -245,9 +245,12 @@ def initDllParser():
|
||||
]
|
||||
ddlAutoValue = pp.Or(map(pp.CaselessKeyword, sorted(ddlAutoKeywords, reverse=True)))
|
||||
|
||||
ddlConstraintKeywords = [
|
||||
ddlPrimaryKey = pp.Group(
|
||||
pp.CaselessKeyword("PRIMARY") + pp.CaselessKeyword("KEY")
|
||||
).setResultsName("isPrimaryKey")
|
||||
|
||||
ddlIgnoredKeywords = [
|
||||
"CONSTRAINT",
|
||||
"PRIMARY",
|
||||
"FOREIGN",
|
||||
"KEY",
|
||||
"FULLTEXT",
|
||||
@@ -257,7 +260,10 @@ def initDllParser():
|
||||
"PERIOD",
|
||||
]
|
||||
ddlConstraint = pp.Group(
|
||||
pp.Or(map(pp.CaselessKeyword, sorted(ddlConstraintKeywords, reverse=True)))
|
||||
pp.Or(map(
|
||||
pp.CaselessKeyword,
|
||||
sorted(ddlIgnoredKeywords + ["PRIMARY"], reverse=True)
|
||||
))
|
||||
+ ddlExpression
|
||||
).setResultsName("isConstraint")
|
||||
|
||||
@@ -272,7 +278,8 @@ def initDllParser():
|
||||
| pp.CaselessKeyword("null")
|
||||
| ddlAutoValue("hasAutoValue")
|
||||
| ddlDefaultValue("hasDefaultValue")
|
||||
| pp.Suppress(pp.OneOrMore(pp.Or(map(pp.CaselessKeyword, sorted(ddlConstraintKeywords, reverse=True)))))
|
||||
| ddlPrimaryKey("isPrimaryKey")
|
||||
| pp.Suppress(pp.OneOrMore(pp.Or(map(pp.CaselessKeyword, sorted(ddlIgnoredKeywords, reverse=True)))))
|
||||
| pp.Suppress(ddlExpression)
|
||||
)
|
||||
)
|
||||
@@ -714,7 +721,7 @@ def createHeader():
|
||||
traitslist.append("sqlpp::tag::must_not_insert")
|
||||
traitslist.append("sqlpp::tag::must_not_update")
|
||||
requireInsert = False
|
||||
if not column.notNull:
|
||||
if not column.notNull and not column.isPrimaryKey:
|
||||
traitslist.append("sqlpp::tag::can_be_null")
|
||||
requireInsert = False
|
||||
if column.hasDefaultValue:
|
||||
|
||||
Reference in New Issue
Block a user