SQLite: Polygon.Length translates to GLength, which returns 0
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start in src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs and compare the Geometry.Length mapping with the provider behavior described here. Reproduce the square query using the supplied setup and check the SQLite spatial function used for polygon length. Done means the SQLite query returns the polygon perimeter, 16, consistently with NetTopologySuite; an open linked pull request indicates work is already underway.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
With the SQLite NetTopologySuite provider, Polygon.Length is translated to GLength, which returns 0 for a polygon. NetTopologySuite returns the polygon's perimeter instead. For the 4×4 square below, the expected result is 16 but the query returns 0.
The SQLite provider's member translator maps Geometry.Length to GLength. The 11.0.0 translator uses the same mapping, although I have not run the repro against 11.0.0.
Related: npgsql/efcore.pg#4151 reports the same mismatch in the PostgreSQL provider's independent translation.
Reproduction
Create a .NET 10 console project with the following package references and install the native mod_spatialite library as described in the SQLite spatial documentation. The repro uses the system SQLite provider, as recommended there for macOS and Linux.
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="10.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite" Version="10.0.15" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.10" />
</ItemGroup>
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using NetTopologySuite.Geometries;
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
var factory = new GeometryFactory(new PrecisionModel(), 4326);
await using var context = new TestContext();
await context.Database.OpenConnectionAsync();
await context.Database.EnsureCreatedAsync();
var polygon = factory.CreatePolygon([new(0, 0), new(4, 0), new(4, 4), new(0, 4), new(0, 0)]);
context.Rows.Add(new Row { Polygon = polygon });
await context.SaveChangesAsync();
Console.WriteLine($"NTS: {polygon.Length}, SQLite: {await context.Rows.Select(r => r.Polygon.Length).SingleAsync()}");
public class TestContext : DbContext
{
public DbSet<Row> Rows => Set<Row>();
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlite("Data Source=:memory:", o => o.UseNetTopologySuite())
.LogTo(Console.WriteLine, LogLevel.Information);
protected override void OnModelCreating(ModelBuilder modelBuilder)
=> modelBuilder.Entity<Row>().Property(r => r.Polygon).HasSrid(4326);
}
public class Row
{
public int Id { get; set; }
public Polygon Polygon { get; set; } = null!;
}
Output:
SELECT GLength("r"."Polygon")
FROM "Rows" AS "r"
LIMIT 2
NTS: 16, SQLite: 0
Environment
- EF Core SQLite NetTopologySuite: 10.0.15
- SpatiaLite: 5.1.0
- .NET: 10.0.8
- macOS arm64
- Ngôn ngữ chính
- C#
- Star
- 14.8k
- Fork
- 3.5k
- Merge trung bình
- 3 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 182
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/efcore
-
customer-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
GroupBy element `OrderBy(...).First()`/`MaxBy` over an owned type mapped to its own table fails to translateCó thể đã có người làm @cincuranet đã nhận hôm nay. Đang mởarea-groupby area-query
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
dotnet/efcore#39833 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Migration lock with LockReleaseBehavior.Transaction doesn't prevent concurrent migrations since per-migration transactionsCó thể đã có người làm @AndriySvyryd đã nhận 1 ngày trước. Đang mởarea-migrations
dotnet/efcore#39824 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Querying a TPC base type with a JSON complex property throwsCó thể đã có người làm @cincuranet đã nhận 1 ngày trước. Đang mởarea-query
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
dotnet/efcore#39814 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Three Cosmos structural-equality tests flaky on Cosmos DB Emulator for WindowsCó thể đã có người làm @su-senka đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 35/100
dotnet/efcore#39809 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của dotnet/efcore
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
SubtitleEdit/subtitleedit#17247 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Restore test cleanup fails on Windows when restored files are read-onlyCó thể đã có người làm @JamBalaya56562 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
duplicati/duplicati#8046 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bundles Documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pyrevitlabs/pyRevit#4285 ·
Maintainer thường phản hồi trong vòng 1 ngày