mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Allow for "IF NOT EXISTS" in createTable in ddl
This commit is contained in:
parent
3d07fe9826
commit
f88efada67
@ -185,7 +185,8 @@ ddlConstraint = Or([
|
||||
ddlWord("UNIQUE"),
|
||||
])
|
||||
ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments])))
|
||||
createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create")
|
||||
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")
|
||||
#ddlString.setDebug(True) #uncomment to debug pyparsing
|
||||
|
||||
ddl = ZeroOrMore(Suppress(SkipTo(createTable, False)) + createTable)
|
||||
@ -222,7 +223,7 @@ types = {
|
||||
}
|
||||
|
||||
ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments])))
|
||||
createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + 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")
|
||||
ddlComment = oneOf(["--", "#"]) + restOfLine
|
||||
|
||||
if failOnParse:
|
||||
|
@ -24,7 +24,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
CREATE TABLE tab_foo
|
||||
CREATE TABLE IF NOT EXISTS tab_foo
|
||||
(
|
||||
delta varchar(255),
|
||||
epsilon bigint,
|
||||
|
Loading…
Reference in New Issue
Block a user