Skip to content
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

Handle nested attribute and block definition equality with Equal() methods #753

Merged
merged 2 commits into from
Jun 12, 2023

Conversation

bflad
Copy link
Member

@bflad bflad commented Jun 9, 2023

Closes #752

Previously before logic updates:

--- FAIL: TestSingleNestedAttributeEqual (0.00s)
    --- FAIL: TestSingleNestedAttributeEqual/different-attribute-definitions (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/datasource/schema/single_nested_attribute_test.go:182: unexpected difference:   bool(
            - 	true,
            + 	false,
              )

…thods

Reference: #752

Previously before logic updates:

```
--- FAIL: TestSingleNestedAttributeEqual (0.00s)
    --- FAIL: TestSingleNestedAttributeEqual/different-attribute-definitions (0.00s)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/datasource/schema/single_nested_attribute_test.go:182: unexpected difference:   bool(
            - 	true,
            + 	false,
              )
```
@bflad bflad added the bug Something isn't working label Jun 9, 2023
@bflad bflad requested a review from a team as a code owner June 9, 2023 18:12
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just one clarifying question 🚀

Comment on lines +29 to +33
if !a.GetNestedObject().Equal(b.GetNestedObject()) {
return false
}

return AttributesEqual(a, b)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that we first compare the nested objects before we compare the attributes? If I'm understanding the BlocksEqual function above it is the other way around (I don't think it matters either way, just curious)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope and in fact, maybe we should compare the "easier" bits first to save a little on performance. Would you want to submit a followup PR to adjust these? (I don't think they need a benchmark test or anything)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, I have no problem submitting the followup PR 👍🏻

@bflad bflad added this to the v1.4.0 milestone Jun 12, 2023
@bflad bflad merged commit abc38b7 into main Jun 12, 2023
19 checks passed
@bflad bflad deleted the bflad/better-nested-schema-equality branch June 12, 2023 14:37
@bflad bflad modified the milestones: v1.4.0, v1.3.1 Jun 13, 2023
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attribute and Block Equal Methods Do Not Account for Nested Attributes/Blocks
2 participants