|
33 | 33 | close_paren = ws* ")" ws* |
34 | 34 | open_repeats = ws* ~r"[\(\[\{]" ws* |
35 | 35 | close_repeats = ws* ~r"[\)\]\}]" ws* |
36 | | - select = ~r"SELECT"i ws+ ~r".+" ws* |
| 36 | + expression = ~r"[\s\S]*" ws* |
37 | 37 | table = ~r"(?:([A-Za-z0-9_\-]+)|`([^\`]+)`)(?:\.(?:([A-Za-z0-9_\-]+)|`([^\`]+)`))?" ws* |
38 | 38 | column = ~r"(?:([A-Za-z0-9_\-]+)|`([^\`]+)`)(?:\.(?:([A-Za-z0-9_\-]+)|`([^\`]+)`))?" ws* |
39 | 39 | link_name = ~r"(?:([A-Za-z0-9_\-]+)|`([^\`]+)`)(?:\.(?:([A-Za-z0-9_\-]+)|`([^\`]+)`))?" ws* |
|
77 | 77 | '<file-type>': r''' |
78 | 78 | file_type = { FILE | FOLDER } |
79 | 79 | ''', |
| 80 | + '<expression>': '', |
80 | 81 | } |
81 | 82 |
|
82 | 83 | BUILTIN_DEFAULTS = { # type: ignore |
@@ -627,6 +628,18 @@ def register(cls, overwrite: bool = False) -> None: |
627 | 628 | cls.compile() |
628 | 629 | registry.register_handler(cls, overwrite=overwrite) |
629 | 630 |
|
| 631 | + def create_result(self) -> result.FusionSQLResult: |
| 632 | + """ |
| 633 | + Create a new result object. |
| 634 | +
|
| 635 | + Returns |
| 636 | + ------- |
| 637 | + FusionSQLResult |
| 638 | + A new result object for this handler |
| 639 | +
|
| 640 | + """ |
| 641 | + return result.FusionSQLResult() |
| 642 | + |
630 | 643 | def execute(self, sql: str) -> result.FusionSQLResult: |
631 | 644 | """ |
632 | 645 | Parse the SQL and invoke the handler method. |
@@ -746,9 +759,9 @@ def visit_init(self, node: Node, visited_children: Iterable[Any]) -> Any: |
746 | 759 | _, out, *_ = visited_children |
747 | 760 | return out |
748 | 761 |
|
749 | | - def visit_select(self, node: Node, visited_children: Iterable[Any]) -> Any: |
750 | | - out = ' '.join(flatten(visited_children)) |
751 | | - return {'select': out} |
| 762 | + def visit_expression(self, node: Node, visited_children: Iterable[Any]) -> Any: |
| 763 | + out = ' '.join(flatten(visited_children)).strip() |
| 764 | + return {'expression': out} |
752 | 765 |
|
753 | 766 | def visit_order_by(self, node: Node, visited_children: Iterable[Any]) -> Any: |
754 | 767 | """Handle ORDER BY.""" |
|
0 commit comments