-
Notifications
You must be signed in to change notification settings - Fork 684
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
wip - Override literal in the case of attribute access of primitive values #6194
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Eduardo Apolinario <[email protected]>
Code Review Agent Run #31d7d8Actionable Suggestions - 1
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
// Check if the current value is a primitive type, and if it is convert that to a literal scalar | ||
if _, ok := currVal.(string); ok { | ||
return &core.Literal{ | ||
Value: &core.Literal_Scalar{ | ||
Scalar: &core.Scalar{ | ||
Value: &core.Scalar_Primitive{ | ||
Primitive: &core.Primitive{ | ||
Value: &core.Primitive_StringValue{ | ||
StringValue: currVal.(string), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} else if _, ok := currVal.(int); ok { | ||
return &core.Literal{ | ||
Value: &core.Literal_Scalar{ | ||
Scalar: &core.Scalar{ | ||
Value: &core.Scalar_Primitive{ | ||
Primitive: &core.Primitive{ | ||
Value: &core.Primitive_Integer{ | ||
Integer: int64(currVal.(int)), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} else if _, ok := currVal.(float64); ok { | ||
return &core.Literal{ | ||
Value: &core.Literal_Scalar{ | ||
Scalar: &core.Scalar{ | ||
Value: &core.Scalar_Primitive{ | ||
Primitive: &core.Primitive{ | ||
Value: &core.Primitive_FloatValue{ | ||
FloatValue: currVal.(float64), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} else if _, ok := currVal.(bool); ok { | ||
return &core.Literal{ | ||
Value: &core.Literal_Scalar{ | ||
Scalar: &core.Scalar{ | ||
Value: &core.Scalar_Primitive{ | ||
Primitive: &core.Primitive{ | ||
Value: &core.Primitive_Boolean{ | ||
Boolean: currVal.(bool), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} |
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.
Consider extracting primitive type conversion logic into a separate helper function to improve code maintainability and reduce duplication. The current implementation has similar conversion patterns repeated for different primitive types.
Code suggestion
Check the AI-generated fix before applying
// Check if the current value is a primitive type, and if it is convert that to a literal scalar | |
if _, ok := currVal.(string); ok { | |
return &core.Literal{ | |
Value: &core.Literal_Scalar{ | |
Scalar: &core.Scalar{ | |
Value: &core.Scalar_Primitive{ | |
Primitive: &core.Primitive{ | |
Value: &core.Primitive_StringValue{ | |
StringValue: currVal.(string), | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, nil | |
} else if _, ok := currVal.(int); ok { | |
return &core.Literal{ | |
Value: &core.Literal_Scalar{ | |
Scalar: &core.Scalar{ | |
Value: &core.Scalar_Primitive{ | |
Primitive: &core.Primitive{ | |
Value: &core.Primitive_Integer{ | |
Integer: int64(currVal.(int)), | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, nil | |
} else if _, ok := currVal.(float64); ok { | |
return &core.Literal{ | |
Value: &core.Literal_Scalar{ | |
Scalar: &core.Scalar{ | |
Value: &core.Scalar_Primitive{ | |
Primitive: &core.Primitive{ | |
Value: &core.Primitive_FloatValue{ | |
FloatValue: currVal.(float64), | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, nil | |
} else if _, ok := currVal.(bool); ok { | |
return &core.Literal{ | |
Value: &core.Literal_Scalar{ | |
Scalar: &core.Scalar{ | |
Value: &core.Scalar_Primitive{ | |
Primitive: &core.Primitive{ | |
Value: &core.Primitive_Boolean{ | |
Boolean: currVal.(bool), | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, nil | |
} | |
// Convert primitive types to literal scalar | |
if lit, err := convertPrimitiveToLiteral(currVal); err == nil { | |
return lit, nil | |
} |
Code Review Run #31d7d8
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6194 +/- ##
==========================================
- Coverage 37.08% 35.39% -1.69%
==========================================
Files 1318 1002 -316
Lines 132707 102296 -30411
==========================================
- Hits 49208 36210 -12998
+ Misses 79244 63091 -16153
+ Partials 4255 2995 -1260
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Tracking issue
N/A
Why are the changes needed?
What changes were proposed in this pull request?
How was this patch tested?
Labels
Please add one or more of the following labels to categorize your PR:
This is important to improve the readability of release notes.
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
This PR enhances the attribute path resolver by adding support for handling primitive type values in binary IDL. The changes introduce automatic conversion of primitive types (string, int, float64, and boolean) into their corresponding literal scalar representations, improving the system's flexibility in attribute handling.Unit tests added: False
Estimated effort to review (1-5, lower is better): 1