Skip to content

Commit

Permalink
Merge PR #168
Browse files Browse the repository at this point in the history
  • Loading branch information
lelit committed Feb 7, 2025
2 parents eed764e + 405e43a commit 8147f7e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pglast/printers/ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3363,16 +3363,16 @@ def variable_set_stmt(node, output):
output.print_list(node.args, ',')
else:
output.print_name(node.name.split('.'))
output.write(' TO ')
if node.kind == vsk.VAR_SET_CURRENT:
output.write(' FROM CURRENT')
else:
output.write(' TO ')
if node.kind == vsk.VAR_SET_VALUE:
output.print_list(node.args)
elif node.kind == vsk.VAR_SET_DEFAULT:
output.write('DEFAULT')
elif node.kind == vsk.VAR_SET_MULTI:
pass
else:
raise NotImplementedError("SET statement of kind %s not implemented yet"
% node.kind)


@node_printer(ast.VariableShowStmt)
Expand Down
13 changes: 13 additions & 0 deletions tests/test_printers_prettification/ddl/create_function.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,16 @@ BEGIN ATOMIC
INSERT INTO bar
VALUES (2, 3);
END

CREATE FUNCTION funcb(somearg text)
RETURNS TABLE(c1 int, c2 text)
AS $$
SELECT 1, 'Label 1'
$$ language sql SET search_path FROM CURRENT
=
CREATE FUNCTION funcb(somearg text)
RETURNS TABLE (c1 integer, c2 text)
AS $$
SELECT 1, 'Label 1'
$$
LANGUAGE sql SET search_path FROM CURRENT
6 changes: 6 additions & 0 deletions tests/test_printers_roundtrip/ddl/create_function.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ $$ language sql
CREATE FUNCTION func() RETURNS SETOF montype AS $$ $$ language sql

CREATE PROCEDURE func() AS $$ $$ language sql

CREATE FUNCTION funcb(somearg text)
RETURNS TABLE(c1 int, c2 text)
AS $$
SELECT 1, 'Label 1'
$$ language sql SET search_path FROM CURRENT

0 comments on commit 8147f7e

Please sign in to comment.