Skip to content

Commit

Permalink
Little stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed May 27, 2022
1 parent 971bb1e commit bbac00d
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}

0 comments on commit bbac00d

Please sign in to comment.