-
Notifications
You must be signed in to change notification settings - Fork 5
Implement native query builder in the CLI plugin #511
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
Conversation
crates/cli/src/native_operations.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add the new commands
@@ -227,6 +229,23 @@ impl From<NativeQueryParts> for String { | |||
} | |||
} | |||
|
|||
impl NativeQueryParts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We introduce a method to prettyprint a native query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We infer information about a Native Operation from a Native Operation SQL string.
/// with other tests. | ||
/// | ||
/// If you have changed it intentionally, run `just generate-configuration`. | ||
pub async fn introspection_is_idempotent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we moved this here from the other tests file.
I'm not allowed to review this because GitHub thinks I wrote it, but I wanted to say that I'm a big fan and would approve it if I could |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What
To improve the DX of native queries, we want a CLI interface with which we can point the CLI at a SQL(ish - a native query) file and generate the stanzas for V3 metadata. This PR sort of does it.
Design
Introduce the following subcommands:
Create
Delete
List
How
The user supplies a file containing SQL(ish - a native operation) code, and specifies the operation kind, and we use the sqlx
describe
method to fetch information about the operation. Specifically, whether it compiles or not, and what is the error if not, and what are the oids of the types of the arguments and returning columns.From this information, we construct a NativeQueryInfo and add it to the configuration, then update it to fetch information about types we might not have tracked in the configuration yet.