Merging upstream version 10.1.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
582b160275
commit
a5128ea109
57 changed files with 1542 additions and 529 deletions
|
@ -22,7 +22,40 @@ class UnsupportedError(SqlglotError):
|
|||
|
||||
|
||||
class ParseError(SqlglotError):
|
||||
pass
|
||||
def __init__(
|
||||
self,
|
||||
message: str,
|
||||
errors: t.Optional[t.List[t.Dict[str, t.Any]]] = None,
|
||||
):
|
||||
super().__init__(message)
|
||||
self.errors = errors or []
|
||||
|
||||
@classmethod
|
||||
def new(
|
||||
cls,
|
||||
message: str,
|
||||
description: t.Optional[str] = None,
|
||||
line: t.Optional[int] = None,
|
||||
col: t.Optional[int] = None,
|
||||
start_context: t.Optional[str] = None,
|
||||
highlight: t.Optional[str] = None,
|
||||
end_context: t.Optional[str] = None,
|
||||
into_expression: t.Optional[str] = None,
|
||||
) -> ParseError:
|
||||
return cls(
|
||||
message,
|
||||
[
|
||||
{
|
||||
"description": description,
|
||||
"line": line,
|
||||
"col": col,
|
||||
"start_context": start_context,
|
||||
"highlight": highlight,
|
||||
"end_context": end_context,
|
||||
"into_expression": into_expression,
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class TokenError(SqlglotError):
|
||||
|
@ -41,9 +74,13 @@ class ExecuteError(SqlglotError):
|
|||
pass
|
||||
|
||||
|
||||
def concat_errors(errors: t.Sequence[t.Any], maximum: int) -> str:
|
||||
def concat_messages(errors: t.Sequence[t.Any], maximum: int) -> str:
|
||||
msg = [str(e) for e in errors[:maximum]]
|
||||
remaining = len(errors) - maximum
|
||||
if remaining > 0:
|
||||
msg.append(f"... and {remaining} more")
|
||||
return "\n\n".join(msg)
|
||||
|
||||
|
||||
def merge_errors(errors: t.Sequence[ParseError]) -> t.List[t.Dict[str, t.Any]]:
|
||||
return [e_dict for error in errors for e_dict in error.errors]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue