From bbac00d4027c36c8fcda2843e88fa695964a6fce Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Fri, 27 May 2022 09:43:46 +0200 Subject: [PATCH] Little stuff --- .../Internal/PostgresFunctionExpression.cs | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/EFCore.PG/Query/Expressions/Internal/PostgresFunctionExpression.cs b/src/EFCore.PG/Query/Expressions/Internal/PostgresFunctionExpression.cs index 83e688cba4..b1534d84e2 100644 --- a/src/EFCore.PG/Query/Expressions/Internal/PostgresFunctionExpression.cs +++ b/src/EFCore.PG/Query/Expressions/Internal/PostgresFunctionExpression.cs @@ -119,7 +119,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) var changed = false; - // Note that we don't have instead functions in PG + // Note that we don't have instance functions in PG SqlExpression[]? visitedArguments = null; @@ -272,29 +272,42 @@ protected override void Print(ExpressionPrinter expressionPrinter) } } - public override bool Equals(object? obj) => obj is PostgresFunctionExpression pgFunction && Equals(pgFunction); + public override bool Equals(object? obj) + => obj is PostgresFunctionExpression pgFunction && Equals(pgFunction); public virtual bool Equals(PostgresFunctionExpression? other) - => ReferenceEquals(this, other) || - other is not null && - base.Equals(other) && - ArgumentNames.SequenceEqual(other.ArgumentNames) && - ArgumentSeparators.SequenceEqual(other.ArgumentSeparators); + => ReferenceEquals(this, other) + || other is not null + && base.Equals(other) + && ArgumentNames.SequenceEqual(other.ArgumentNames) + && ArgumentSeparators.SequenceEqual(other.ArgumentSeparators) + && AggregateOrderings.SequenceEqual(other.AggregateOrderings) + && (AggregatePredicate is null && other.AggregatePredicate is null + || AggregatePredicate != null && AggregatePredicate.Equals(other.AggregatePredicate)); public override int GetHashCode() { var hash = new HashCode(); + hash.Add(base.GetHashCode()); + foreach (var argumentName in ArgumentNames) { - hash.Add(argumentName?.GetHashCode()); + hash.Add(argumentName); } foreach (var argumentSeparator in ArgumentSeparators) { - hash.Add(argumentSeparator?.GetHashCode() ?? 0); + hash.Add(argumentSeparator); + } + + foreach (var aggregateOrdering in AggregateOrderings) + { + hash.Add(aggregateOrdering); } + hash.Add(AggregatePredicate); + return hash.ToHashCode(); } } \ No newline at end of file