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

Validating CLI arguments #561

Merged
merged 25 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ae2f54d
Validating CLI arguments
tl3119 May 31, 2023
2be9e6a
Merge branch 'master' of https://github.com/tl3119/jupysql
tl3119 May 31, 2023
38be8a0
Validating CLI arguments
tl3119 Jun 1, 2023
cd093c2
Merge pull request #1 from ploomber/master
tl3119 Jun 1, 2023
a52c5e6
remove rec_arguments array and add tests for line magic and cell magic
tl3119 Jun 1, 2023
acc2f06
Merge branch 'master' of https://github.com/tl3119/jupysql
tl3119 Jun 1, 2023
f06d7cc
Merge pull request #2 from ploomber/master
tl3119 Jun 1, 2023
08a540f
Update docs to use --alias
tl3119 Jun 2, 2023
3fca85d
Merge branch 'master' of https://github.com/tl3119/jupysql
tl3119 Jun 2, 2023
beec9e2
Remove pinned pydata version
tl3119 Jun 5, 2023
16f794f
Validating CLI arguments update
tl3119 Jun 5, 2023
3055c77
Update PR
tl3119 Jun 5, 2023
79efad6
Update PR, fix irrelevant issues
tl3119 Jun 6, 2023
7200eef
Update magic logic and test
tl3119 Jun 6, 2023
90ed427
Update test_magic.py
tl3119 Jun 7, 2023
219a47c
update PR
tl3119 Jun 7, 2023
553f49f
update PR
tl3119 Jun 7, 2023
43b35c3
Merge pull request #3 from ploomber/master
tl3119 Jun 7, 2023
7203acf
fix check only for cell magic
tl3119 Jun 7, 2023
468f365
Merge branch 'master' of https://github.com/tl3119/jupysql
tl3119 Jun 7, 2023
a410d91
Merge pull request #5 from ploomber/master
tl3119 Jun 7, 2023
68310ea
pass multiple arguments to pytest parameterized
tl3119 Jun 7, 2023
e5d4e9b
Merge branch 'master' of https://github.com/tl3119/jupysql
tl3119 Jun 7, 2023
cb8b636
Update PR
tl3119 Jun 7, 2023
42e4f24
Merge pull request #6 from ploomber/master
tl3119 Jun 7, 2023
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
5 changes: 5 additions & 0 deletions src/sql/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,14 @@ def check_random_arguments(self, line="", cell=""):

# Iterate through the tokens to separate arguments and SQL code
tl3119 marked this conversation as resolved.
Show resolved Hide resolved
# If the token starts with "--", it is an argument
breakLoop = False
for token in tokens:
if token.startswith("--"):
arguments.append(token)
breakLoop = True
else:
if breakLoop:
break

declared_argument = _option_strings_from_parser(SqlMagic.execute.parser)
# check only for cell magic
Expand Down
13 changes: 11 additions & 2 deletions src/tests/test_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,17 @@ def test_persist_no_index(ip):
assert persisted == [(1, "foo"), (2, "bar")]


def test_unrecognized_arguments_cell_magic(ip):
result = ip.run_cell("%%sql --stuff \n SELECT * FROM test")
@pytest.mark.parametrize(
"sql_statement",
[
"%%sql --stuff\n SELECT * FROM test",
"%%sql --unknown\n SELECT * FROM test",
"%%sql --invalid-arg\n SELECT * FROM test",
"%sql select * from penguins.csv limit --some sql comment",
mehtamohit013 marked this conversation as resolved.
Show resolved Hide resolved
],
)
def test_unrecognized_arguments_cell_magic(ip, sql_statement):
result = ip.run_cell(sql_statement)
assert "Unrecognized argument(s)" in str(result.error_in_exec)

tl3119 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down