Skip to content

Commit

Permalink
Update logic for explicit collate or extra parenthesis
Browse files Browse the repository at this point in the history
Signed-off-by: Shameem Ahmed <shameemahmed20apr2000@gmail.com>
  • Loading branch information
ahmed-shameem committed Jan 13, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fdefc5f commit aae6e31
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions contrib/babelfishpg_tsql/src/pltsql_ruleutils.c
Original file line number Diff line number Diff line change
@@ -1434,14 +1434,16 @@ get_rule_expr(Node *node, deparse_context *context,
CollateExpr *collate = (CollateExpr *) node;
Node *arg = (Node *) collate->arg;

const char *dump_restore = GetConfigOption("babelfishpg_tsql.dump_restore", true, false);
// const char *dump_restore = GetConfigOption("babelfishpg_tsql.dump_restore", true, false);

if (!PRETTY_PAREN(context) && (!dump_restore || (dump_restore && strcmp(dump_restore, "on") != 0)))
// if (!PRETTY_PAREN(context) && (!dump_restore || (dump_restore && strcmp(dump_restore, "on") != 0)))
if (!PRETTY_PAREN(context))
appendStringInfoChar(buf, '(');
get_rule_expr_paren(arg, context, showimplicit, node);
appendStringInfo(buf, " COLLATE %s",
generate_tsql_collation_name(collate->collOid));
if (!PRETTY_PAREN(context) && (!dump_restore || (dump_restore && strcmp(dump_restore, "on") != 0)))
// if (!PRETTY_PAREN(context) && (!dump_restore || (dump_restore && strcmp(dump_restore, "on") != 0)))
if (!PRETTY_PAREN(context))
appendStringInfoChar(buf, ')');
}
break;
@@ -2648,10 +2650,11 @@ get_coercion_expr(Node *arg, deparse_context *context,
}
else
{
if (!PRETTY_PAREN(context))
const char *dump_restore = GetConfigOption("babelfishpg_tsql.dump_restore", true, false);
if (!PRETTY_PAREN(context) && (!dump_restore || (dump_restore && strcmp(dump_restore, "on") != 0)))
appendStringInfoChar(buf, '(');
get_rule_expr_paren(arg, context, false, parentNode);
if (!PRETTY_PAREN(context))
if (!PRETTY_PAREN(context) && (!dump_restore || (dump_restore && strcmp(dump_restore, "on") != 0)))
appendStringInfoChar(buf, ')');
}

0 comments on commit aae6e31

Please sign in to comment.