Skip to content

Commit a598a70

Browse files
committed
Generate schema name for function calls
1 parent b90896c commit a598a70

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

sqlparser/lib/utils/node_to_text.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,10 @@ class NodeSqlBuilder extends AstVisitor<void, void> {
725725

726726
@override
727727
void visitFunction(FunctionExpression e, void arg) {
728+
if (e.schemaName != null) {
729+
identifier(e.schemaName!, spaceAfter: false);
730+
symbol('.');
731+
}
728732
identifier(e.name);
729733
symbol('(');
730734
visit(e.parameters, arg);

sqlparser/test/utils/node_to_text_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,15 @@ CREATE UNIQUE INDEX my_idx ON t1 (c1, c2, c3) WHERE c1 < c3;
517517
testFormat('SELECT my_function(*) FROM foo');
518518
testFormat('SELECT my_function(DISTINCT a, b) FROM foo');
519519
testFormat('SELECT my_function(a, b) FROM foo');
520+
521+
expect(
522+
FunctionExpression(
523+
name: 'bar',
524+
schemaName: 'foo',
525+
parameters: ExprFunctionParameters())
526+
.toSql(),
527+
'foo.bar()',
528+
);
520529
});
521530

522531
test('is', () {

0 commit comments

Comments
 (0)