diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-29 13:02:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-29 13:02:29 +0000 |
commit | 9b39dac84e82bf473216939e50b8836170f01d23 (patch) | |
tree | 9b405bc86ef7e2ea28cddc6b787ed70355cf7fce /sqlglot/dialects/postgres.py | |
parent | Releasing debian version 16.4.2-1. (diff) | |
download | sqlglot-9b39dac84e82bf473216939e50b8836170f01d23.tar.xz sqlglot-9b39dac84e82bf473216939e50b8836170f01d23.zip |
Merging upstream version 16.7.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/postgres.py')
-rw-r--r-- | sqlglot/dialects/postgres.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sqlglot/dialects/postgres.py b/sqlglot/dialects/postgres.py index 8c2a4ab..766b584 100644 --- a/sqlglot/dialects/postgres.py +++ b/sqlglot/dialects/postgres.py @@ -11,6 +11,7 @@ from sqlglot.dialects.dialect import ( format_time_lambda, max_or_greatest, min_or_least, + no_map_from_entries_sql, no_paren_current_date_sql, no_pivot_sql, no_tablesample_sql, @@ -346,6 +347,7 @@ class Postgres(Dialect): exp.LogicalOr: rename_func("BOOL_OR"), exp.LogicalAnd: rename_func("BOOL_AND"), exp.Max: max_or_greatest, + exp.MapFromEntries: no_map_from_entries_sql, exp.Min: min_or_least, exp.ArrayOverlaps: lambda self, e: self.binary(e, "&&"), exp.ArrayContains: lambda self, e: self.binary(e, "@>"), @@ -378,3 +380,11 @@ class Postgres(Dialect): exp.TransientProperty: exp.Properties.Location.UNSUPPORTED, exp.VolatileProperty: exp.Properties.Location.UNSUPPORTED, } + + def bracket_sql(self, expression: exp.Bracket) -> str: + """Forms like ARRAY[1, 2, 3][3] aren't allowed; we need to wrap the ARRAY.""" + if isinstance(expression.this, exp.Array): + expression = expression.copy() + expression.set("this", exp.paren(expression.this, copy=False)) + + return super().bracket_sql(expression) |