fixed parser bug in create table as

initial support for <sql> blocks
This commit is contained in:
2022-11-17 05:49:32 +08:00
parent 5b1e8063fb
commit 4792bfa08f
4 changed files with 28 additions and 9 deletions
+2 -2
View File
@@ -243,8 +243,8 @@ RESERVED = MatchFirst([
WITHIN,
INTO,
])
L_INLINE = Literal("<k>").suppress()
R_INLINE = Literal("</k>").suppress()
L_INLINE = Literal("<sql>").suppress()
R_INLINE = Literal("</sql>").suppress()
LBRACE = Literal("{").suppress()
RBRACE = Literal("}").suppress()
LSB = Literal("[").suppress()
+5 -4
View File
@@ -66,7 +66,7 @@ def parser(literal_string, ident, sqlserver=False):
var_name = ~RESERVED + ident
inline_kblock = (L_INLINE + SkipTo(R_INLINE, include=True))("c")
inline_sqlblock = (L_INLINE + SkipTo(R_INLINE, include=True))("sql")
# EXPRESSIONS
expr = Forward()
column_type, column_definition, column_def_references = get_column_type(
@@ -569,8 +569,9 @@ def parser(literal_string, ident, sqlserver=False):
| assign("comment", EQ + literal_string)
| assign("default character set", EQ + var_name)
| assign("default charset", EQ + var_name)
)
+ Optional(AS.suppress() + infix_notation(query, [])("query"))
)
+ Optional(AS.suppress() + query("query"))
# investigate why infix_notation(query, []) eats up the rest of queries
)("create_table")
create_view = (
@@ -724,7 +725,7 @@ def parser(literal_string, ident, sqlserver=False):
)("stmts"), ";")
other_stmt = (
inline_kblock
inline_sqlblock
| udf
) ("stmts")