-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rendering error of column's DEFAULT with an expression
This fixes the case raised in pganalyze/libpg_query#188.
- Loading branch information
Showing
2 changed files
with
8 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# :Created: gio 09 nov 2017 10:50:30 CET | ||
# :Author: Lele Gaifax <[email protected]> | ||
# :License: GNU General Public License version 3 or later | ||
# :Copyright: © 2017, 2018, 2019, 2020, 2021, 2022 Lele Gaifax | ||
# :Copyright: © 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lele Gaifax | ||
# | ||
|
||
import re | ||
|
@@ -1172,7 +1172,11 @@ def CONSTR_CHECK(self, node, output): | |
def CONSTR_DEFAULT(self, node, output): | ||
output.swrite('DEFAULT ') | ||
assert not (node.raw_expr is not None and node.cooked_expr is not None) | ||
output.print_node(node.cooked_expr if node.raw_expr is None else node.raw_expr) | ||
expr = node.cooked_expr if node.raw_expr is None else node.raw_expr | ||
# Handle the ``DEFAULT (1 IN (1, 2))`` case as seen here: | ||
# https://github.com/postgres/postgres/blob/REL_14_STABLE/src/test/regress/input/constraints.source#L41 | ||
with output.expression(isinstance(expr, ast.A_Expr)): | ||
output.print_node(expr) | ||
|
||
def CONSTR_EXCLUSION(self, node, output): | ||
output.swrite('EXCLUDE USING ') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters