Skip to content

fix #3116 instances of gethashcode in equals implementation #3117

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

Merged
merged 2 commits into from
Mar 6, 2018

Conversation

Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Mar 1, 2018

No description provided.

@Mpdreamz Mpdreamz requested review from russcam and codebrain March 1, 2018 20:37
Copy link
Contributor

@russcam russcam left a comment

Choose a reason for hiding this comment

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

Left some comments

)
);
}

private static bool EqualsAllIndices(IReadOnlyList<IndexName> indicesCurrent, IReadOnlyList<IndexName> indicesOther)
Copy link
Contributor

Choose a reason for hiding this comment

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

thisIndices and otherIndices?

if (indicesCurrent == null && indicesOther == null) return true;
if (indicesCurrent == null || indicesOther == null) return false;
if (indicesCurrent.Count != indicesOther.Count) return false;
return indicesCurrent.Zip(indicesOther, Tuple.Create).All(t=>t.Item1.Equals(t.Item2));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should also take into account the order of indices e.g.

Indices indices1 = "foo,bar";    
Indices indices2 = "bar,foo";    
(indices1 == indices2).Should().BeTrue();

)
);
}

private static bool EqualsAllTypes(IReadOnlyList<TypeName> indicesCurrent, IReadOnlyList<TypeName> indicesOther)
Copy link
Contributor

Choose a reason for hiding this comment

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

thisTypes and otherTypes?

if (indicesCurrent == null && indicesOther == null) return true;
if (indicesCurrent == null || indicesOther == null) return false;
if (indicesCurrent.Count != indicesOther.Count) return false;
return indicesCurrent.Zip(indicesOther, Tuple.Create).All(t=>t.Item1.Equals(t.Item2));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should also take into account the order

@Mpdreamz
Copy link
Member Author

Mpdreamz commented Mar 4, 2018

All good points @russcam, addressed them in followup commit.

@Mpdreamz Mpdreamz merged commit d806e32 into master Mar 6, 2018
@Mpdreamz Mpdreamz deleted the fix/types-equals branch March 6, 2018 19:17
Mpdreamz added a commit that referenced this pull request Mar 6, 2018
* fix #3116 instances of gethashcode in equals implementation

* Equals on types and indices now ignores order and implements == operator

Conflicts:
	src/Nest/CommonAbstractions/Infer/RelationName/RelationName.cs
	src/Tests/ClientConcepts/HighLevel/Inference/TypesAndRelationsInference.doc.cs
	src/Tests/Framework/Configuration/Versions/ElasticsearchVersion.cs
	src/Tests/Framework/ElasticsearchVersionTests.cs
Mpdreamz added a commit that referenced this pull request Mar 6, 2018
* fix #3116 instances of gethashcode in equals implementation

* Equals on types and indices now ignores order and implements == operator

Conflicts:
	src/Nest/CommonAbstractions/Infer/Indices/Indices.cs
	src/Nest/CommonAbstractions/Infer/Types/Types.cs
@Mpdreamz
Copy link
Member Author

Mpdreamz commented Mar 6, 2018

backported to 5.x and 6.x`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants