jupysql icon indicating copy to clipboard operation
jupysql copied to clipboard

Snippets get saved even when a snippet query is not correct

Open wrothmir opened this issue 2 years ago • 1 comments

What happens?

Snippets get saved regardless of their correctness.

Acceptance Criteria: Any snippet that does not execute correctly if the --no-execute flag is not passed must not be saved.

To Reproduce

%load_ext sql
%sql duckdb://
%%sql
create table languages (name VARCHAR, rating INTEGER)
insert into languages values ('Python', 1), ('Java', 0), ('OCaml', 2)

The following is not a correct query and does not execute.

%%sql --save language_lt1
select * from languages where

But, it gets saved and can be viewed using %sqlcmd magic.

%sqlcmd snippets language_lt1

Output:

select * from languages where

OS:

Linux

JupySQL Version:

0.10.2dev

Full Name:

Vineet Agarwal

Affiliation:

Ploomber

wrothmir avatar Sep 15 '23 04:09 wrothmir

goot catch! this indeed looks like a bug, note that we have a --no-execute flag so in that case, users could save broken snippets. but if the flag isn't present, then yes, we should not save them. we should also display a message saying that the snippet wasn't stored

edublancas avatar Sep 15 '23 15:09 edublancas