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

close #1031 #1032

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions src/sql/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,23 +586,23 @@ def interactive_execute_wrapper(**kwargs):
and not isinstance(result, str)
and self.column_local_vars
):
# Instead of returning values, set variables directly in the
# users namespace. Variable names given by column names
# Set variables directly in the users namespace.
# Variable names given by column names

if self.autopandas or self.autopolars:
keys = result.keys()
self.shell.user_ns.update(result)
result = None
else:
keys = result.keys
result = result.dict()
self.shell.user_ns.update(result.dict())

if self.feedback:
display.message(
"Returning data to local variables [{}]".format(", ".join(keys))
)

self.shell.user_ns.update(result)

return None
return result
else:
if command.result_var:
self.shell.user_ns.update({command.result_var: result})
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def test_displaylimit_with_count_statement(ip, load_penguin, config_value):
def test_column_local_vars(ip):
ip.run_line_magic("config", "SqlMagic.column_local_vars = True")
result = runsql(ip, "SELECT * FROM author;")
assert result is None
assert result is not None
assert "William" in ip.user_global_ns["first_name"]
assert "Shakespeare" in ip.user_global_ns["last_name"]
assert len(ip.user_global_ns["first_name"]) == 2
Expand Down
Loading