Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add printer for setting config from current #168

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Comment on lines -3373 to -3375
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VAR_SET_CURRENT is the last option, so it doesn't make sense leaving this here anymore.



@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
Loading