Skip to content
New issue

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

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

Already on GitHub? # to your account

identifier validation edge case #842

Closed
edublancas opened this issue Aug 28, 2023 · 1 comment · Fixed by #848
Closed

identifier validation edge case #842

edublancas opened this issue Aug 28, 2023 · 1 comment · Fixed by #848
Assignees

Comments

@edublancas
Copy link

I encountered an edge case when validating the passed argument to%sql:

running rollback; or commit; should be interpreted as SQL commands (it works if I remove the ;). I think if the argument in %sql ends in ; we can be confident that this is SQL code and we should not validate it.

In [1]: %load_ext sql
Found pyproject.toml from '/Users/eduardo/Desktop/test-jupysql-dev-dsn-file'

In [2]: %sql duckdb://

In [3]: %sql rollback;
UsageError: 'rollback;' is not a valid connection identifier. Please pass the variable's name directly, as passing object attributes, dictionaries or lists won't work.
If you need help solving this issue, send us a message: https://ploomber.io/community

In [4]: %sql commit;
UsageError: 'commit;' is not a valid connection identifier. Please pass the variable's name directly, as passing object attributes, dictionaries or lists won't work.
If you need help solving this issue, send us a message: https://ploomber.io/community

In [5]: %sql commit
Running query in 'duckdb://'
Out[5]:
+---------+
| Success |
+---------+
+---------+

In [6]: %sql rollback
Running query in 'duckdb://'
Out[6]:
+---------+
| Success |
+---------+
+---------+
@bbeat2782
Copy link

Acceptance Criteria

  1. Ensure if an argument passed into %sql has ; at the end, it should be interpreted as SQL commands
  2. Add test case for this

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants