Skip to content

Commit e5f31d1

Browse files
CopilotPhenX
andauthored
Add regression tests for List<E> properties with PostgreSQL array columns (#99)
* Add tests for List<E> properties and PostgreSQL array columns Agent-Logs-Url: https://github.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/sessions/5895f1a5-7481-4d46-ad56-4185202559fd Co-authored-by: PhenX <42170+PhenX@users.noreply.github.com> * Fix net10 build errors: upgrade Microting MySql NTS package and fix namespace Agent-Logs-Url: https://github.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/sessions/3f27f5f0-246a-4335-a151-598367d015f7 Co-authored-by: PhenX <42170+PhenX@users.noreply.github.com> * Add targeted regression tests for issue #98 (List<E> inserted as empty array) Agent-Logs-Url: https://github.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/sessions/35321946-6e22-4fef-ae93-63fcb4d9a4cb Co-authored-by: PhenX <42170+PhenX@users.noreply.github.com> * Add HasColumnType test, clean up comments, add copilot instructions Agent-Logs-Url: https://github.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/sessions/061e8659-734e-4464-a9ff-d6d3d55f5ded Co-authored-by: PhenX <42170+PhenX@users.noreply.github.com> * Add positional-record entity and test for enum list bulk insert Agent-Logs-Url: https://github.com/PhenX/PhenX.EntityFrameworkCore.BulkInsert/sessions/d8061788-70e3-42d4-877f-6147dbf98c84 Co-authored-by: PhenX <42170+PhenX@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: PhenX <42170+PhenX@users.noreply.github.com>
1 parent 35154ee commit e5f31d1

8 files changed

Lines changed: 416 additions & 1 deletion

File tree

.github/copilot-instructions.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copilot Instructions
2+
3+
## Code style
4+
5+
- Do not add comments that describe the current investigation, debugging session, or reasoning
6+
process. Comments should explain *what* code does or *why* a design decision was made, not
7+
document an ongoing investigation.
8+
- Do not include "issue #N", "triangulate", "hypothesis", or similar investigation language in
9+
inline code comments or block comments inside method bodies. Such context belongs in the pull
10+
request description, not in the source code.

tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContainer/TestDbContainerMySql.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
using PhenX.EntityFrameworkCore.BulkInsert.MySql;
88

9+
#if !NET10_0_OR_GREATER
910
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
11+
#else
12+
using Microting.EntityFrameworkCore.MySql.Infrastructure;
13+
#endif
1014

1115
using Testcontainers.MySql;
1216

tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/DbContext/TestDbContext.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
7171

7272
public class TestDbContextPostgreSql : TestDbContext
7373
{
74+
public DbSet<TestEntityWithArrays> TestEntitiesWithArrays { get; set; } = null!;
75+
public DbSet<TestEntityWithEnumList> TestEntitiesWithEnumList { get; set; } = null!;
76+
public DbSet<TestEntityWithEnumArray> TestEntitiesWithEnumArray { get; set; } = null!;
77+
public DbSet<TestEntityWithIntList> TestEntitiesWithIntList { get; set; } = null!;
78+
public DbSet<TestEntityWithEnumListExplicitType> TestEntitiesWithEnumListExplicitType { get; set; } = null!;
79+
public DbSet<TestRecordWithEnumList> TestRecordsWithEnumList { get; set; } = null!;
80+
7481
protected override void OnModelCreating(ModelBuilder modelBuilder)
7582
{
7683
base.OnModelCreating(modelBuilder);
@@ -85,6 +92,17 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
8592
{
8693
b.Property(x => x.StringEnumValue).HasColumnType("text");
8794
});
95+
96+
modelBuilder.Entity<TestEntityWithEnumListExplicitType>(b =>
97+
{
98+
b.Property(x => x.EnumList).HasColumnType("integer[]");
99+
});
100+
101+
modelBuilder.Entity<TestRecordWithEnumList>(b =>
102+
{
103+
b.Property(x => x.TestRun).HasColumnName("test_run");
104+
b.Property(x => x.Values).HasColumnName("values");
105+
});
88106
}
89107
}
90108

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.ComponentModel.DataAnnotations.Schema;
2+
3+
namespace PhenX.EntityFrameworkCore.BulkInsert.Tests.DbContext;
4+
5+
[Table("test_entity_with_arrays")]
6+
public class TestEntityWithArrays : TestEntityBase
7+
{
8+
public int Id { get; set; }
9+
10+
[Column("enum_list")]
11+
public List<NumericEnum>? EnumList { get; set; }
12+
13+
[Column("int_array")]
14+
public int[]? IntArray { get; set; }
15+
16+
[Column("string_array")]
17+
public string[]? StringArray { get; set; }
18+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System.ComponentModel.DataAnnotations.Schema;
2+
3+
using Microsoft.EntityFrameworkCore;
4+
5+
namespace PhenX.EntityFrameworkCore.BulkInsert.Tests.DbContext;
6+
7+
[PrimaryKey(nameof(Id))]
8+
[Table("test_entity_with_enum_list")]
9+
public class TestEntityWithEnumList : TestEntityBase
10+
{
11+
public int Id { get; set; }
12+
13+
[Column("enum_list")]
14+
public List<NumericEnum> EnumList { get; set; } = [];
15+
}
16+
17+
[PrimaryKey(nameof(Id))]
18+
[Table("test_entity_with_enum_array")]
19+
public class TestEntityWithEnumArray : TestEntityBase
20+
{
21+
public int Id { get; set; }
22+
23+
[Column("enum_array")]
24+
public NumericEnum[] EnumArray { get; set; } = [];
25+
}
26+
27+
[PrimaryKey(nameof(Id))]
28+
[Table("test_entity_with_int_list")]
29+
public class TestEntityWithIntList : TestEntityBase
30+
{
31+
public int Id { get; set; }
32+
33+
[Column("int_list")]
34+
public List<int> IntList { get; set; } = [];
35+
}
36+
37+
/// <summary>
38+
/// Same as <see cref="TestEntityWithEnumList"/> but its <c>List&lt;NumericEnum&gt;</c>
39+
/// property is additionally configured with <c>HasColumnType("integer[]")</c> via
40+
/// Fluent API, which is a common pattern in user code.
41+
/// </summary>
42+
[PrimaryKey(nameof(Id))]
43+
[Table("test_entity_with_enum_list_explicit_type")]
44+
public class TestEntityWithEnumListExplicitType : TestEntityBase
45+
{
46+
public int Id { get; set; }
47+
48+
[Column("enum_list")]
49+
public List<NumericEnum> EnumList { get; set; } = [];
50+
}
51+
52+
/// <summary>
53+
/// Positional record that mirrors the reporter's shape:
54+
/// <c>record Item(List&lt;E&gt; Values)</c>.
55+
/// Properties are <c>init</c>-only, populated via the primary constructor.
56+
/// </summary>
57+
[PrimaryKey(nameof(Id))]
58+
[Table("test_record_with_enum_list")]
59+
public record TestRecordWithEnumList(int Id, Guid TestRun, List<NumericEnum> Values);

tests/PhenX.EntityFrameworkCore.BulkInsert.Tests/PhenX.EntityFrameworkCore.BulkInsert.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<ItemGroup Label="NetTopologySuite net10.0" Condition="'$(TargetFramework)' == 'net10.0'">
5050
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="10.0.2" />
5151
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite" Version="10.0.0" />
52-
<PackageReference Include="Microting.EntityFrameworkCore.MySql.NetTopologySuite" Version="10.0.5" />
52+
<PackageReference Include="Microting.EntityFrameworkCore.MySql.NetTopologySuite" Version="10.0.7" />
5353
</ItemGroup>
5454

5555
<ItemGroup Label="Specific dependencies">

0 commit comments

Comments
 (0)