diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-17 10:32:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-17 10:32:16 +0000 |
commit | d3bb537b2b73788ba06bf4158f473ecc5bb556cc (patch) | |
tree | 6c1b280de128c7bf77baaa258560a1f39a4e15c7 /sqlglot/__init__.py | |
parent | Releasing debian version 10.4.2-1. (diff) | |
download | sqlglot-d3bb537b2b73788ba06bf4158f473ecc5bb556cc.tar.xz sqlglot-d3bb537b2b73788ba06bf4158f473ecc5bb556cc.zip |
Merging upstream version 10.5.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/__init__.py')
-rw-r--r-- | sqlglot/__init__.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sqlglot/__init__.py b/sqlglot/__init__.py index 04c3195..87fa081 100644 --- a/sqlglot/__init__.py +++ b/sqlglot/__init__.py @@ -32,7 +32,7 @@ from sqlglot.parser import Parser from sqlglot.schema import MappingSchema from sqlglot.tokens import Tokenizer, TokenType -__version__ = "10.4.2" +__version__ = "10.5.2" pretty = False @@ -60,9 +60,9 @@ def parse( def parse_one( sql: str, read: t.Optional[str | Dialect] = None, - into: t.Optional[Expression | str] = None, + into: t.Optional[t.Type[Expression] | str] = None, **opts, -) -> t.Optional[Expression]: +) -> Expression: """ Parses the given SQL string and returns a syntax tree for the first parsed SQL statement. @@ -83,7 +83,12 @@ def parse_one( else: result = dialect.parse(sql, **opts) - return result[0] if result else None + for expression in result: + if not expression: + raise ParseError(f"No expression was parsed from '{sql}'") + return expression + else: + raise ParseError(f"No expression was parsed from '{sql}'") def transpile( |