From 7ee41aad0f76f0f38cfa078b2b52accf12c25226 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 4 Dec 2023 00:39:04 -0800 Subject: [PATCH 01/16] temporary fix; need to run tests --- src/sql/parse.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sql/parse.py b/src/sql/parse.py index f38922651..091d68723 100644 --- a/src/sql/parse.py +++ b/src/sql/parse.py @@ -230,7 +230,7 @@ def without_sql_comment(parser, line): args = _option_strings_from_parser(parser) result = itertools.takewhile( lambda word: (not word.startswith("--")) or (word in args), - shlex.split(line, posix=False), + line.split() ) return " ".join(result) @@ -300,8 +300,7 @@ def magic_args(magic_execute, line, cmd_from, allowed_duplicates=None): line = without_sql_comment(parser=magic_execute.parser, line=line) arg_line, sql_line = split_args_and_sql(line) - args = shlex.split(arg_line, posix=False) - + args = arg_line.split() if len(args) > 1: check_duplicate_arguments(magic_execute, cmd_from, args, allowed_duplicates) From 13e7b70d214260250725dd43e738c68d1002722e Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 4 Dec 2023 02:04:23 -0800 Subject: [PATCH 02/16] formatted --- src/sql/parse.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sql/parse.py b/src/sql/parse.py index 091d68723..05c48eacd 100644 --- a/src/sql/parse.py +++ b/src/sql/parse.py @@ -229,8 +229,7 @@ def without_sql_comment(parser, line): args = _option_strings_from_parser(parser) result = itertools.takewhile( - lambda word: (not word.startswith("--")) or (word in args), - line.split() + lambda word: (not word.startswith("--")) or (word in args), line.split() ) return " ".join(result) From 513ff3a43bb2f825d144566747fe798013fa8054 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 4 Dec 2023 02:07:01 -0800 Subject: [PATCH 03/16] added changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 791b43647..ea7d01999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.10.8dev +* [Fix] Fixed bug where the `%sql` line magic would not parse properly due to expectations from shlex(#954) + ## 0.10.7 (2023-12-23) * [Feature] Add Spark Connection as a dialect for Jupysql ([#965](https://github.com/ploomber/jupysql/issues/965)) (by [@gilandose](https://github.com/gilandose)) From ff2a751ec9742f07af2644fa0a84068a8a46f8d9 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 18 Dec 2023 14:43:55 +0530 Subject: [PATCH 04/16] working fix --- src/sql/parse.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/sql/parse.py b/src/sql/parse.py index 05c48eacd..66de5fafe 100644 --- a/src/sql/parse.py +++ b/src/sql/parse.py @@ -228,10 +228,16 @@ def without_sql_comment(parser, line): """ args = _option_strings_from_parser(parser) + pattern = re.compile(r'([\'"])(.*?)\1') + temp_line = pattern.sub(lambda x: x.group().replace(" ", ""), line) + spaces_removed = len(line) - len(temp_line) result = itertools.takewhile( - lambda word: (not word.startswith("--")) or (word in args), line.split() + lambda word: (not word.startswith("--")) or (word in args), + temp_line.split() ) - return " ".join(result) + result = " ".join(result) + result = line[:len(result) + spaces_removed] + return result def split_args_and_sql(line): @@ -273,20 +279,18 @@ def split_args_and_sql(line): # If any SQL commands are found in the line, we split the line into args and sql. # Note: lines without SQL commands will not be split # ex. %sql duckdb:// or %sqlplot boxplot --table data.csv - if not any(cmd in line_no_filenames for cmd in SQL_COMMANDS): - return arg_line, sql_line - - # Identify beginning of sql query using keywords - split_idx = -1 - for token in line.split(): - if token.lower() in SQL_COMMANDS: - # Found index at which to split line - split_idx = line.find(token) - break - - # Split line into args and sql, beginning at sql keyword - if split_idx != -1: - arg_line, sql_line = line[:split_idx], line[split_idx:] + if any(cmd in line_no_filenames for cmd in SQL_COMMANDS) or any(cmd.upper() in line_no_filenames for cmd in SQL_COMMANDS): + # Identify beginning of sql query using keywords + split_idx = -1 + for token in line.split(): + if token.lower() in SQL_COMMANDS: + # Found index at which to split line + split_idx = line.find(token) + break + + # Split line into args and sql, beginning at sql keyword + if split_idx != -1: + arg_line, sql_line = line[:split_idx], line[split_idx:] return arg_line, sql_line @@ -299,14 +303,14 @@ def magic_args(magic_execute, line, cmd_from, allowed_duplicates=None): line = without_sql_comment(parser=magic_execute.parser, line=line) arg_line, sql_line = split_args_and_sql(line) - args = arg_line.split() + args = shlex.split(arg_line, posix=False) if len(args) > 1: check_duplicate_arguments(magic_execute, cmd_from, args, allowed_duplicates) parsed = magic_execute.parser.parse_args(args) if sql_line: - parsed.line = shlex.split(sql_line, posix=False) + parsed.line = sql_line.split() return parsed From 96aaa5b43dd45a2c021bec51f2d483a4679df1dd Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 18 Dec 2023 14:44:07 +0530 Subject: [PATCH 05/16] added tests --- src/tests/test_parse.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tests/test_parse.py b/src/tests/test_parse.py index 3ea46041c..4bcda6e31 100644 --- a/src/tests/test_parse.py +++ b/src/tests/test_parse.py @@ -772,7 +772,7 @@ def test_connections_file_get_default_connection_url(tmp_empty, content, expecte ), ( "select 'hello'[:-2]", - "hell", + "hel", ), ], ) @@ -897,6 +897,11 @@ def test_escape_string_slicing_notation(query, expected_escaped, expected_found) "-p --save snippet -N ", "insert into authors values('[100]'::json->0)", ), + ( + "--save snippet SELECT TRIM(' padded ')", + "--save snippet ", + "SELECT TRIM(' padded ')", + ), ], ids=[ "no-query", @@ -910,6 +915,7 @@ def test_escape_string_slicing_notation(query, expected_escaped, expected_found) "update", "delete", "insert", + "select-uppercase", ], ) def test_split_args_and_sql(line, expected_args, expected_sql): From 7c5be391440c17969f74ab4b4655da7ce0a228b1 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 18 Dec 2023 14:44:37 +0530 Subject: [PATCH 06/16] formatted file --- src/sql/parse.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sql/parse.py b/src/sql/parse.py index 66de5fafe..f4d4baed3 100644 --- a/src/sql/parse.py +++ b/src/sql/parse.py @@ -232,11 +232,10 @@ def without_sql_comment(parser, line): temp_line = pattern.sub(lambda x: x.group().replace(" ", ""), line) spaces_removed = len(line) - len(temp_line) result = itertools.takewhile( - lambda word: (not word.startswith("--")) or (word in args), - temp_line.split() + lambda word: (not word.startswith("--")) or (word in args), temp_line.split() ) result = " ".join(result) - result = line[:len(result) + spaces_removed] + result = line[: len(result) + spaces_removed] return result @@ -279,7 +278,9 @@ def split_args_and_sql(line): # If any SQL commands are found in the line, we split the line into args and sql. # Note: lines without SQL commands will not be split # ex. %sql duckdb:// or %sqlplot boxplot --table data.csv - if any(cmd in line_no_filenames for cmd in SQL_COMMANDS) or any(cmd.upper() in line_no_filenames for cmd in SQL_COMMANDS): + if any(cmd in line_no_filenames for cmd in SQL_COMMANDS) or any( + cmd.upper() in line_no_filenames for cmd in SQL_COMMANDS + ): # Identify beginning of sql query using keywords split_idx = -1 for token in line.split(): From 6a4f010ef674c4f9fc26eba3ab4cff151df7522c Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 18 Dec 2023 14:50:25 +0530 Subject: [PATCH 07/16] added test for case where -- is preceded by space in queries --- src/tests/test_parse.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tests/test_parse.py b/src/tests/test_parse.py index 4bcda6e31..0ffcad987 100644 --- a/src/tests/test_parse.py +++ b/src/tests/test_parse.py @@ -263,6 +263,12 @@ def test_without_sql_comment_dashes_in_string(): assert without_sql_comment(parser=parser_stub, line=line) == expected +def test_without_sql_comment_dashes_in_string_with_spaces(): + line = "SELECT ' --very --confusing ' FROM author -- uff da" + expected = "SELECT ' --very --confusing ' FROM author" + assert without_sql_comment(parser=parser_stub, line=line) == expected + + def test_without_sql_comment_with_arg_and_leading_comment(): line = "--file moo.txt --persist --comment, not arg" expected = "--file moo.txt --persist" From d2bf6e59447e54b6abb007b82ba61cae8529f0e5 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 18 Dec 2023 14:53:57 +0530 Subject: [PATCH 08/16] fixed unknown error --- src/tests/test_parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/test_parse.py b/src/tests/test_parse.py index 0ffcad987..e32fac416 100644 --- a/src/tests/test_parse.py +++ b/src/tests/test_parse.py @@ -777,8 +777,8 @@ def test_connections_file_get_default_connection_url(tmp_empty, content, expecte "ell", ), ( - "select 'hello'[:-2]", - "hel", + "select 'hello'[:-1]", + "hell", ), ], ) From c29d5189bacc87d5db6a89e89b049f4406cff469 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 18 Dec 2023 15:01:00 +0530 Subject: [PATCH 09/16] trigger checks From 4c229289b3731c0aeb3653abccfcf7de2cf5ace6 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Mon, 18 Dec 2023 17:48:30 +0530 Subject: [PATCH 10/16] fixed breaking tests --- src/tests/test_magic.py | 45 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/tests/test_magic.py b/src/tests/test_magic.py index c2dd8f155..b95a260c4 100644 --- a/src/tests/test_magic.py +++ b/src/tests/test_magic.py @@ -2466,6 +2466,9 @@ def test_query_comment_after_semicolon(ip, query, expected): assert list(result.dict().values())[-1][0] == expected +error_message_link = "https://jupysql.ploomber.io/en/latest/compose.html#with-argument" + + @pytest.mark.parametrize( "query, error_type, error_message", [ @@ -2474,33 +2477,32 @@ def test_query_comment_after_semicolon(ip, query, expected): SELECT * FROM snip; SELECT * from temp;""", "TableNotFoundError", - """If using snippets, you may pass the --with argument explicitly. -For more details please refer: \ -https://jupysql.ploomber.io/en/latest/compose.html#with-argument + f"""If using snippets, you may pass the --with argument explicitly. +For more details please refer: {error_message_link} There is no table with name 'snip'. Did you mean: 'snippet' Original error message from DB driver: -(duckdb.duckdb.CatalogException) Catalog Error: Table with name snip does not exist! +(duckdb.CatalogException) Catalog Error: Table with name snip does not exist! Did you mean "temp"? LINE 1: SELECT * FROM snip; ^ -[SQL: SELECT * FROM snip;]""", +[SQL: SELECT * FROM snip;] +""", ), ( """%%sql SELECT * FROM snippet; SELECT * from tem;""", "RuntimeError", - """If using snippets, you may pass the --with argument explicitly. -For more details please refer: \ -https://jupysql.ploomber.io/en/latest/compose.html#with-argument + f"""If using snippets, you may pass the --with argument explicitly. +For more details please refer: {error_message_link} Original error message from DB driver: -(duckdb.duckdb.CatalogException) Catalog Error: Table with name tem does not exist! +(duckdb.CatalogException) Catalog Error: Table with name tem does not exist! Did you mean "temp"? LINE 1: SELECT * from tem; ^ @@ -2511,16 +2513,15 @@ def test_query_comment_after_semicolon(ip, query, expected): SELECT * FROM snip; SELECT * from tem;""", "TableNotFoundError", - """If using snippets, you may pass the --with argument explicitly. -For more details please refer: \ -https://jupysql.ploomber.io/en/latest/compose.html#with-argument + f"""If using snippets, you may pass the --with argument explicitly. +For more details please refer: {error_message_link} There is no table with name 'snip'. Did you mean: 'snippet' Original error message from DB driver: -(duckdb.duckdb.CatalogException) Catalog Error: Table with name snip does not exist! +(duckdb.CatalogException) Catalog Error: Table with name snip does not exist! Did you mean "temp"? LINE 1: SELECT * FROM snip; ^ @@ -2531,17 +2532,17 @@ def test_query_comment_after_semicolon(ip, query, expected): SELECT * FROM s; SELECT * from temp;""", "RuntimeError", - """If using snippets, you may pass the --with argument explicitly. -For more details please refer: \ -https://jupysql.ploomber.io/en/latest/compose.html#with-argument + f"""If using snippets, you may pass the --with argument explicitly. +For more details please refer: {error_message_link} Original error message from DB driver: -(duckdb.duckdb.CatalogException) Catalog Error: Table with name s does not exist! +(duckdb.CatalogException) Catalog Error: Table with name s does not exist! Did you mean "temp"? LINE 1: SELECT * FROM s; ^ -[SQL: SELECT * FROM s;]""", +[SQL: SELECT * FROM s;] +""", ), ( """%%sql @@ -2549,13 +2550,12 @@ def test_query_comment_after_semicolon(ip, query, expected): SELECT * FROM snippet; SELECT * from temp;""", "RuntimeError", - """If using snippets, you may pass the --with argument explicitly. -For more details please refer: \ -https://jupysql.ploomber.io/en/latest/compose.html#with-argument + f"""If using snippets, you may pass the --with argument explicitly. +For more details please refer: {error_message_link} Original error message from DB driver: -(duckdb.duckdb.CatalogException) Catalog Error: Table with name snippet does not exist! +(duckdb.CatalogException) Catalog Error: Table with name snippet does not exist! Did you mean "pg_type"? LINE 1: SELECT * FROM snippet; ^ @@ -2595,6 +2595,7 @@ def test_table_does_not_exist_with_snippet_error( ip_empty.run_cell(query) # Test error and message + print(excinfo.value) assert error_type == excinfo.value.error_type assert error_message in str(excinfo.value) From ab819ad4fa3c8af35f33b67628f24b5439fd510e Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Tue, 26 Dec 2023 14:39:27 +0530 Subject: [PATCH 11/16] fixed breaking tests due to wrong splitting of argument and sql_lines --- src/sql/parse.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sql/parse.py b/src/sql/parse.py index f4d4baed3..20c35982f 100644 --- a/src/sql/parse.py +++ b/src/sql/parse.py @@ -229,13 +229,12 @@ def without_sql_comment(parser, line): args = _option_strings_from_parser(parser) pattern = re.compile(r'([\'"])(.*?)\1') - temp_line = pattern.sub(lambda x: x.group().replace(" ", ""), line) - spaces_removed = len(line) - len(temp_line) + line = pattern.sub(lambda match: match.group().replace(" ", "@@SPACE@@"), line) result = itertools.takewhile( - lambda word: (not word.startswith("--")) or (word in args), temp_line.split() + lambda word: (not word.startswith("--")) or (word in args), line.split() ) result = " ".join(result) - result = line[: len(result) + spaces_removed] + result = result.replace("@@SPACE@@", " ") return result @@ -278,7 +277,13 @@ def split_args_and_sql(line): # If any SQL commands are found in the line, we split the line into args and sql. # Note: lines without SQL commands will not be split # ex. %sql duckdb:// or %sqlplot boxplot --table data.csv - if any(cmd in line_no_filenames for cmd in SQL_COMMANDS) or any( + if "<<" in line: + [before_assign, after_assign] = line.split("<<") + result_var = before_assign.split()[-1] + arg_line = " ".join(before_assign.split()[:-1]) + sql_line = result_var + " << " + after_assign + + elif any(cmd in line_no_filenames for cmd in SQL_COMMANDS) or any( cmd.upper() in line_no_filenames for cmd in SQL_COMMANDS ): # Identify beginning of sql query using keywords From b44633f8ece06ec4f4b1a8fb998422292047c01e Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Tue, 26 Dec 2023 15:22:43 +0530 Subject: [PATCH 12/16] reset tests --- src/tests/test_magic.py | 45 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/tests/test_magic.py b/src/tests/test_magic.py index b95a260c4..c2dd8f155 100644 --- a/src/tests/test_magic.py +++ b/src/tests/test_magic.py @@ -2466,9 +2466,6 @@ def test_query_comment_after_semicolon(ip, query, expected): assert list(result.dict().values())[-1][0] == expected -error_message_link = "https://jupysql.ploomber.io/en/latest/compose.html#with-argument" - - @pytest.mark.parametrize( "query, error_type, error_message", [ @@ -2477,32 +2474,33 @@ def test_query_comment_after_semicolon(ip, query, expected): SELECT * FROM snip; SELECT * from temp;""", "TableNotFoundError", - f"""If using snippets, you may pass the --with argument explicitly. -For more details please refer: {error_message_link} + """If using snippets, you may pass the --with argument explicitly. +For more details please refer: \ +https://jupysql.ploomber.io/en/latest/compose.html#with-argument There is no table with name 'snip'. Did you mean: 'snippet' Original error message from DB driver: -(duckdb.CatalogException) Catalog Error: Table with name snip does not exist! +(duckdb.duckdb.CatalogException) Catalog Error: Table with name snip does not exist! Did you mean "temp"? LINE 1: SELECT * FROM snip; ^ -[SQL: SELECT * FROM snip;] -""", +[SQL: SELECT * FROM snip;]""", ), ( """%%sql SELECT * FROM snippet; SELECT * from tem;""", "RuntimeError", - f"""If using snippets, you may pass the --with argument explicitly. -For more details please refer: {error_message_link} + """If using snippets, you may pass the --with argument explicitly. +For more details please refer: \ +https://jupysql.ploomber.io/en/latest/compose.html#with-argument Original error message from DB driver: -(duckdb.CatalogException) Catalog Error: Table with name tem does not exist! +(duckdb.duckdb.CatalogException) Catalog Error: Table with name tem does not exist! Did you mean "temp"? LINE 1: SELECT * from tem; ^ @@ -2513,15 +2511,16 @@ def test_query_comment_after_semicolon(ip, query, expected): SELECT * FROM snip; SELECT * from tem;""", "TableNotFoundError", - f"""If using snippets, you may pass the --with argument explicitly. -For more details please refer: {error_message_link} + """If using snippets, you may pass the --with argument explicitly. +For more details please refer: \ +https://jupysql.ploomber.io/en/latest/compose.html#with-argument There is no table with name 'snip'. Did you mean: 'snippet' Original error message from DB driver: -(duckdb.CatalogException) Catalog Error: Table with name snip does not exist! +(duckdb.duckdb.CatalogException) Catalog Error: Table with name snip does not exist! Did you mean "temp"? LINE 1: SELECT * FROM snip; ^ @@ -2532,17 +2531,17 @@ def test_query_comment_after_semicolon(ip, query, expected): SELECT * FROM s; SELECT * from temp;""", "RuntimeError", - f"""If using snippets, you may pass the --with argument explicitly. -For more details please refer: {error_message_link} + """If using snippets, you may pass the --with argument explicitly. +For more details please refer: \ +https://jupysql.ploomber.io/en/latest/compose.html#with-argument Original error message from DB driver: -(duckdb.CatalogException) Catalog Error: Table with name s does not exist! +(duckdb.duckdb.CatalogException) Catalog Error: Table with name s does not exist! Did you mean "temp"? LINE 1: SELECT * FROM s; ^ -[SQL: SELECT * FROM s;] -""", +[SQL: SELECT * FROM s;]""", ), ( """%%sql @@ -2550,12 +2549,13 @@ def test_query_comment_after_semicolon(ip, query, expected): SELECT * FROM snippet; SELECT * from temp;""", "RuntimeError", - f"""If using snippets, you may pass the --with argument explicitly. -For more details please refer: {error_message_link} + """If using snippets, you may pass the --with argument explicitly. +For more details please refer: \ +https://jupysql.ploomber.io/en/latest/compose.html#with-argument Original error message from DB driver: -(duckdb.CatalogException) Catalog Error: Table with name snippet does not exist! +(duckdb.duckdb.CatalogException) Catalog Error: Table with name snippet does not exist! Did you mean "pg_type"? LINE 1: SELECT * FROM snippet; ^ @@ -2595,7 +2595,6 @@ def test_table_does_not_exist_with_snippet_error( ip_empty.run_cell(query) # Test error and message - print(excinfo.value) assert error_type == excinfo.value.error_type assert error_message in str(excinfo.value) From f897b8884797cc798f903234be1feba9dbe0c4e4 Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Tue, 26 Dec 2023 15:29:12 +0530 Subject: [PATCH 13/16] testing broken test fix --- src/tests/test_parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/test_parse.py b/src/tests/test_parse.py index e32fac416..0ffcad987 100644 --- a/src/tests/test_parse.py +++ b/src/tests/test_parse.py @@ -777,8 +777,8 @@ def test_connections_file_get_default_connection_url(tmp_empty, content, expecte "ell", ), ( - "select 'hello'[:-1]", - "hell", + "select 'hello'[:-2]", + "hel", ), ], ) From 6755b15dfd5c786ecbe7da51f0b10731b62952fb Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Tue, 26 Dec 2023 15:31:54 +0530 Subject: [PATCH 14/16] testing broken test fix --- src/tests/test_parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/test_parse.py b/src/tests/test_parse.py index 0ffcad987..60af05d29 100644 --- a/src/tests/test_parse.py +++ b/src/tests/test_parse.py @@ -777,8 +777,8 @@ def test_connections_file_get_default_connection_url(tmp_empty, content, expecte "ell", ), ( - "select 'hello'[:-2]", - "hel", + "select 'hello'[:-3]", + "he", ), ], ) From 4701e6e57ba24edd469a215d6d8a3e1f0bbfa11e Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Tue, 26 Dec 2023 15:36:39 +0530 Subject: [PATCH 15/16] testing broken test fix --- src/tests/test_parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/test_parse.py b/src/tests/test_parse.py index 60af05d29..60ec8d1b9 100644 --- a/src/tests/test_parse.py +++ b/src/tests/test_parse.py @@ -777,8 +777,8 @@ def test_connections_file_get_default_connection_url(tmp_empty, content, expecte "ell", ), ( - "select 'hello'[:-3]", - "he", + "select 'hello'[:-2]", + "hell", ), ], ) From 3957a0c0afed69f1b68f0fa570196e8b2a822f6e Mon Sep 17 00:00:00 2001 From: Vineet Agarwal Date: Tue, 26 Dec 2023 16:47:42 +0530 Subject: [PATCH 16/16] fixed column guesser test --- src/tests/test_column_guesser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/test_column_guesser.py b/src/tests/test_column_guesser.py index 6c01a60f3..62e267b77 100644 --- a/src/tests/test_column_guesser.py +++ b/src/tests/test_column_guesser.py @@ -12,7 +12,8 @@ def __init__(self, connectstr): self.connectstr = connectstr def query(self, txt): - return ip.run_line_magic("sql", "%s %s" % (self.connectstr, txt)) + ip.run_line_magic("sql", self.connectstr) + return ip.run_line_magic("sql", "%s" % txt) sql_env = SqlEnv("sqlite://")