SQLite: Polygon.Length translates to GLength, which returns 0
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- C#
- スター
- 14.8k
- フォーク
- 3.5k
- 平均マージ
- 3日 7時間
- マージ済み PR(30日)
- 182
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/efcore のほかの issue
-
customer-reported
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
GroupBy element `OrderBy(...).First()`/`MaxBy` over an owned type mapped to its own table fails to translate対応中かも @cincuranet が今日担当しました。 オープンarea-groupby area-query
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
dotnet/efcore#39833 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
Migration lock with LockReleaseBehavior.Transaction doesn't prevent concurrent migrations since per-migration transactions対応中かも @AndriySvyryd が 1 日前に担当しました。 オープンarea-migrations
dotnet/efcore#39824 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
Querying a TPC base type with a JSON complex property throws対応中かも @cincuranet が 1 日前に担当しました。 オープンarea-query
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
dotnet/efcore#39814 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
Three Cosmos structural-equality tests flaky on Cosmos DB Emulator for Windows対応中かも @su-senka が 1 日前に担当しました。 オープン
難易度 3/5 半日 初心者へのやさしさ 35/100
dotnet/efcore#39809 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
SubtitleEdit/subtitleedit#17247 ·
メンテナーはふだん 1 日以内に返信
-
Restore test cleanup fails on Windows when restored files are read-only対応中かも @JamBalaya56562 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
duplicati/duplicati#8046 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
Bundles Documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pyrevitlabs/pyRevit#4285 ·
メンテナーはふだん 1 日以内に返信