You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cli: let infoctl query take SQL that starts with a comment #96
infoctl query takes the SQL as one quoted argument, and parse_query treats every argument that starts with -- as an option (crates/cli/src/lib.rs:107 at b3017eb on PR #46's branch). A statement that opens with a SQL line comment, as saved queries and editor snippets often do, is therefore refused before it is parsed:
and the command exits 2. There is also no way to pass such a statement, because the parser has no end-of-options marker. Take the convention other command lines use: a bare -- ends option parsing and everything after it is the SQL. On top of that, an argument that starts with -- but contains whitespace cannot be an option, so it can be taken as SQL without the marker; a typo such as --verbose has no whitespace and stays a usage error.
Crate:crates/cli (src/lib.rs: parse_query and USAGE; tests/query.rs or the unit tests in src/lib.rs)
Done when
infoctl query "-- daily totals\nselect 1", one argument holding a newline, runs the query and exits 0.
infoctl query --format csv -- "select 1" runs the query with CSV output, and infoctl query -- --format treats --format as the SQL and fails as SQL with exit 1, not as a usage error with exit 2.
infoctl query --verbose "select 1" still exits 2 with unknown option --verbose, and --warehouse and --format keep working before the --.
The QUERY: block of USAGE shows the -- marker.
Each case above is a test, and each test fails when the parser is put back to treating every -- argument as an option.
Points: 1
Depends on:#15 (the parser PR #46 adds) Blocks: nothing
Activity
feat(cli): infoctl query runs read-only SQL against the warehouse (#46)