-
Notifications
You must be signed in to change notification settings - Fork 5
Support nested fields of object type #404
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
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'm still in the process of reviewing and nothing seems to jump out, but I would appreciate more comments/docstrings on a few places, there are a couple of very large functions that do not have documentation.
| /// | ||
| /// - `row_to_json` takes a row and converts it to a json object. | ||
| /// - `coalesce(<thing>, <otherwise>)` returns `<thing>` if it is not null, and `<otherwise>` if it is null. |
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.
This part is probably copy paste from the with_default version right? :)
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.
Right - I've pruned it more now. Thanks
|
|
||
| /// Translate rows part of query to sql ast. | ||
| pub fn translate_rows_query( | ||
| struct JoinNestedFieldInfo { |
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.
Please add a docstring.
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.
done.
| alias: sql::ast::TableAlias, | ||
| } | ||
|
|
||
| fn transalate_nested_field_joins(joins: Vec<JoinNestedFieldInfo>) -> Vec<sql::ast::Join> { |
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.
Please add a docstring.
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.
done
| join_nested_fields: &mut Vec<JoinNestedFieldInfo>, | ||
| join_relationship_fields: &mut Vec<relationships::JoinFieldInfo>, | ||
| ) -> Result<sql::ast::ColumnReference, Error> { | ||
| match field { |
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 would really appreciate some comments in-between some code chunks summarizing what they do. Rust can be quite verbose and it gives some direction to reading the code (and also easier to verify the intent matches the code).
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.
Agree! I've added some commentary explaining how translate_nested_field goes about its business.
| state: &mut State, | ||
| // The table reference the column lives on | ||
| current_table: &TableNameAndReference, | ||
| // The column to extract nested fields from |
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.
Can these be ///? Does that work?
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.
It seems rust does not support /// (or #[doc()] attributes) on function arguments. I've moved these to the main /// block under an # Aruguments heading.
I'm fine either way myself.
|
@soupi: Thanks for the review. I've tried to improve the documentation :-) |
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 think this makes sense to me. Nice!
What
This PR adds support for selecting nested fields that arise from composite objects.
The case for nested fields which are arrays will be treated in a followup PR.
How
The SQL generated is of the form