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

(GH-143) Handle order insensitive arrays in the same? method of the DSC Base Provider #148

Merged
merged 1 commit into from
May 25, 2021
Merged

(GH-143) Handle order insensitive arrays in the same? method of the DSC Base Provider #148

merged 1 commit into from
May 25, 2021

Conversation

michaeltlombardi
Copy link
Contributor

Prior to this PR, a typo in the case statement of the same? method in the DSC Base Provider caused the Hash and Array cases never to run, always falling back on a simple == value comparison.

This caused arrays which were the same except for ordering to always fail, as == comparisons of arrays are order sensitive.

This PR corrects the typo, ensuring that the Array case runs. This only handles order insensitivity of arrays which have no nested values.

A future PR will be required to deeply sort arrays and hashes - see #144 for further details.

This PR also comments out the Hash case, which otherwise errors. This preserves existing behavior for Hashes, causing them to be compared with ==, which is order insensitive for keys but not for array values (this also will be resolved when #144 is implemented.

Prior to this commit, a typo in the case statement of the same? method
in the DSC Base Provider caused the Hash and Array cases never to run,
always falling back on a simple == value comparison.

This caused arrays which were the same except for ordering to always
fail, as == comparisons of arrays are order sensitive.

This commit corrects the typo, ensuring that the Array case runs. This
only handles order insensitivity of arrays which have no nested values.

A future commit will be required to deeply sort arrays and hashes - see
#144 for further details.

This commit also comments out the Hash case, which otherwise errors. This
preserves existing behavior for Hashes, causing them to be compared with
==, which is order insensitive for _keys_ but not for array values (this
also will be resolved when #144 is implemented.

- Resolves #143
@michaeltlombardi michaeltlombardi requested a review from a team as a code owner May 24, 2021 21:55
@jpogran jpogran merged commit 2836e7b into puppetlabs:main May 25, 2021
@michaeltlombardi michaeltlombardi deleted the gh-143/main/handle-order-insensitive-arrays-in-same branch May 27, 2021 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

same? in the DSC Base provider does not handle order-insensitive array comparisons
2 participants