-
Notifications
You must be signed in to change notification settings - Fork 185
RUST-2198 Add run_raw_command
method
#1356
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
@beckerinj thank you for this PR! I'll discuss this addition with the team early next week and get back to you on whether we would like to add this to the driver API. |
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.
I discussed with the team and we agreed that this is a nice addition to our API. I have a suggestion for reducing duplication in the action types; please let me know if you have any questions!
run_raw_command
method
fix docs don't change formatting
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.
lgtm!
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.
Apologies, hit approve before checking CI. It looks like compilation is broken with in-use-encryption
enabled.
I suspected there are some other dependents which need changing under the different flags. |
I believe the latest commit should fix the |
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.
one last fix needed based on the CI run, after that this should be good to go
src/action/run_command.rs
Outdated
match session.transaction.state { | ||
TransactionState::Starting | TransactionState::InProgress => { | ||
if self.command.contains_key("readConcern") { | ||
if command.get("readConcern").ok().is_some() { |
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.
if command.get("readConcern").ok().is_some() { | |
if command.get("readConcern").is_ok_and(|rc| rc.is_some()) { |
get
returns an error if the document is malformed, so this as currently written will evaluate to true for any valid document
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.
Got it, made this change 👍
Apologies my formatter keeps auto formatting the imports, I just undid it again. |
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.
thanks for the formatting fix, lgtm! @abr-egn this is ready for your review
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.
Thank you for the contribution! Changes LGTM with a doc fix and suggested test.
Cheers, no problem, I've made the requested changes and added the test. |
The database
run_command
api only takes a Document, while internally it is later converted to a RawDocumentBuf before execution. In a situation where you already have the command as a RawDocumentBuf in the first place, an unneeded conversion RawDocumentBuf -> Document -> RawDocumentBuf is required to use this API.I noticed that there was this
RunCommand::new_raw
method, which was feature gated behind "in-use-encryption". I'm not sure the reason for this gate, but it's trivial to remove it and use it with the additionaldatabase.raw_run_command
method added here.I only added
raw_run_command
, but a similarraw_run_cursor_command
could also be added which takes RawDocumentBuf as well.