0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Various additions to ddl2cpp for MySQL (#416)

This commit is contained in:
Zach Toogood 2022-01-16 18:22:17 +02:00 committed by GitHub
parent b8aed2af55
commit 62f987ef44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -226,11 +226,12 @@ ddlConstraint = Or([
ddlWord("PRIMARY"), ddlWord("PRIMARY"),
ddlWord("FOREIGN"), ddlWord("FOREIGN"),
ddlWord("KEY"), ddlWord("KEY"),
ddlWord("FULLTEXT"),
ddlWord("INDEX"), ddlWord("INDEX"),
ddlWord("UNIQUE"), ddlWord("UNIQUE"),
ddlWord("CHECK") ddlWord("CHECK")
]) ])
ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlUnsigned, ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments, ddlMathCond]))) ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlUnsigned, ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlFunctionWord("current_timestamp"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments, ddlMathCond])))
ddlIfNotExists = Optional(Group(ddlWord("IF") + ddlWord("NOT") + ddlWord("EXISTS")).setResultsName("ifNotExists")) ddlIfNotExists = Optional(Group(ddlWord("IF") + ddlWord("NOT") + ddlWord("EXISTS")).setResultsName("ifNotExists"))
createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlIfNotExists + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create") createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlIfNotExists + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create")
#ddlString.setDebug(True) #uncomment to debug pyparsing #ddlString.setDebug(True) #uncomment to debug pyparsing
@ -293,6 +294,10 @@ types = {
'int unsigned': 'integer_unsigned', #MYSQL 'int unsigned': 'integer_unsigned', #MYSQL
'bigint unsigned': 'bigint_unsigned', #MYSQL 'bigint unsigned': 'bigint_unsigned', #MYSQL
'mediumint unsigned' : 'integer', #MYSQL 'mediumint unsigned' : 'integer', #MYSQL
'tinytext' : 'text', #MYSQL
'binary' : 'blob', #MYSQL
'varbinary' : 'blob', #MYSQL
'float unsigned' : 'floating_point', #MYSQL
} }
if failOnParse: if failOnParse: