Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/EFCore.PG/Storage/Internal/Mapping/NpgsqlArrayTypeMapping.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#region License

// The PostgreSQL License
//
// Copyright (C) 2016 The Npgsql Development Team
Expand All @@ -19,13 +20,13 @@
// AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
// ON AN "AS IS" BASIS, AND THE NPGSQL DEVELOPMENT TEAM HAS NO OBLIGATIONS
// TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

#endregion

using System;
using System.Text;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.EntityFrameworkCore.ChangeTracking;

Expand All @@ -45,26 +46,23 @@ public class NpgsqlArrayTypeMapping : RelationalTypeMapping
/// Creates the default array mapping (i.e. for the single-dimensional CLR array type)
/// </summary>
public NpgsqlArrayTypeMapping(string storeType, RelationalTypeMapping elementMapping)
: this(storeType, elementMapping, elementMapping.ClrType.MakeArrayType())
{}
: this(storeType, elementMapping, elementMapping.ClrType.MakeArrayType()) {}

/// <summary>
/// Creates the default array mapping (i.e. for the single-dimensional CLR array type)
/// </summary>
public NpgsqlArrayTypeMapping(RelationalTypeMapping elementMapping, Type arrayType)
: this(elementMapping.StoreType + "[]", elementMapping, arrayType)
{}
: this(elementMapping.StoreType + "[]", elementMapping, arrayType) {}

NpgsqlArrayTypeMapping(string storeType, RelationalTypeMapping elementMapping, Type arrayType)
: base(new RelationalTypeMappingParameters(
new CoreTypeMappingParameters(arrayType, null, CreateComparer(elementMapping, arrayType)), storeType
))
{
ElementMapping = elementMapping;
}
=> ElementMapping = elementMapping;

protected NpgsqlArrayTypeMapping(RelationalTypeMappingParameters parameters, RelationalTypeMapping elementMapping)
: base(parameters) {}
: base(parameters)
=> ElementMapping = elementMapping;

public override RelationalTypeMapping Clone(string storeType, int? size)
=> new NpgsqlArrayTypeMapping(StoreType, ElementMapping);
Expand All @@ -87,6 +85,7 @@ protected override string GenerateNonNullSqlLiteral(object value)
if (i < arr.Length - 1)
sb.Append(",");
}

sb.Append("]");
return sb.ToString();
}
Expand Down Expand Up @@ -157,7 +156,7 @@ static TElem[] Snapshot(TElem[] source, ValueComparer<TElem> elementComparer)
class SingleDimComparerWithIEquatable<TElem> : ValueComparer<TElem[]>
where TElem : IEquatable<TElem>
{
public SingleDimComparerWithIEquatable(): base(
public SingleDimComparerWithIEquatable() : base(
(a, b) => Compare(a, b),
o => o.GetHashCode(), // TODO: Need to get hash code of elements...
source => DoSnapshot(source)) {}
Expand All @@ -180,6 +179,7 @@ static bool Compare(TElem[] a, TElem[] b)
continue;
return false;
}

if (!elem1.Equals(elem2))
return false;
}
Expand Down Expand Up @@ -224,6 +224,7 @@ static bool Compare(TElem[] a, TElem[] b)
continue;
return false;
}

if (!elem1.Equals(elem2))
return false;
}
Expand Down