diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-03 07:31:54 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-03 07:31:54 +0000 |
commit | b38d717d5933fdae3fe85c87df7aee9a251fb58e (patch) | |
tree | 6db21a44ffea4c832dcab29688bfaf1c1dc124f9 /sqlglot/helper.py | |
parent | Releasing debian version 11.4.1-1. (diff) | |
download | sqlglot-b38d717d5933fdae3fe85c87df7aee9a251fb58e.tar.xz sqlglot-b38d717d5933fdae3fe85c87df7aee9a251fb58e.zip |
Merging upstream version 11.4.5.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/helper.py')
-rw-r--r-- | sqlglot/helper.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sqlglot/helper.py b/sqlglot/helper.py index 6eff974..d44d7dd 100644 --- a/sqlglot/helper.py +++ b/sqlglot/helper.py @@ -59,7 +59,7 @@ def ensure_list(value): """ if value is None: return [] - elif isinstance(value, (list, tuple)): + if isinstance(value, (list, tuple)): return list(value) return [value] @@ -162,9 +162,7 @@ def camel_to_snake_case(name: str) -> str: return CAMEL_CASE_PATTERN.sub("_", name).upper() -def while_changing( - expression: t.Optional[Expression], func: t.Callable[[t.Optional[Expression]], E] -) -> E: +def while_changing(expression: Expression, func: t.Callable[[Expression], E]) -> E: """ Applies a transformation to a given expression until a fix point is reached. @@ -176,8 +174,13 @@ def while_changing( The transformed expression. """ while True: + for n, *_ in reversed(tuple(expression.walk())): + n._hash = hash(n) start = hash(expression) expression = func(expression) + + for n, *_ in expression.walk(): + n._hash = None if start == hash(expression): break return expression |