Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7aa8be0
Bump version to 9.0.1
roji Nov 18, 2024
2e9a27f
Depend on Npgsql 9.0.1 (#3376)
roji Nov 19, 2024
051d00c
Bump version to 9.0.2
roji Nov 19, 2024
17e2fc8
Restore virtual modifier (#3382)
virzak Nov 20, 2024
697dd71
Bump Npgsql dependency to 9.0.2
roji Dec 7, 2024
e5e901e
Bump version to 9.0.3
roji Dec 7, 2024
c240ce5
Redo enum label addition (#3425)
roji Dec 28, 2024
2e59bf5
Fix quoted enum handling (#3434)
roji Jan 17, 2025
74b858a
Depend on EF 9.0.1
roji Jan 17, 2025
e4a74e7
Bump version to 9.0.4
roji Jan 17, 2025
badb51e
Fix calling base method in NpgsqlMigrationsSqlGenerator (#3443)
roji Jan 27, 2025
953ad1c
Generate UUIDv7 values for value-generated strings (#3462)
roji Feb 14, 2025
e952c84
Stop testing on PG12 (out of support)
roji Feb 14, 2025
6a34455
Always close connection after reloading types in migration. (#3465)
marcusber Feb 15, 2025
0fdf784
Fix nullability for IndexOf (array_position) (#3477)
roji Feb 28, 2025
4bf3248
Preserve collation when changing column type (#3479)
roji Feb 28, 2025
80ec4ae
Preserve ConfigureDataSource() callback when applying other context o…
roji Mar 1, 2025
fd23809
Bump Npgsql to 9.0.3
roji Mar 1, 2025
5da4a58
Attempt to implement IntersectsBbox
bjornharrtell Mar 1, 2025
c4c729c
Fix test
bjornharrtell Mar 1, 2025
c4a87db
Merge branch 'main' into intersects-bbox
bjornharrtell Feb 1, 2026
94f23a3
Fix merge
bjornharrtell Feb 1, 2026
27db760
Remove not used using
bjornharrtell Feb 1, 2026
58807f2
Add summary
bjornharrtell Feb 1, 2026
72ff57c
Fix test case expect syntax
bjornharrtell Feb 1, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ namespace Microsoft.EntityFrameworkCore;
/// </summary>
public static class NpgsqlNetTopologySuiteDbFunctionsExtensions
{
/// <summary>
/// Checks whether the 2D bounding boxes of two geometries intersect.
/// Translates to the PostGIS <c>&amp;&amp;</c> operator.
/// </summary>
public static bool IntersectsBbox(this DbFunctions _, Geometry geometry, Geometry anotherGeometry)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(IntersectsBbox)));

/// <summary>
/// Returns a new geometry with its coordinates transformed to a different spatial reference system.
/// Translates to <c>ST_Transform(geometry, srid)</c>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ var t when typeof(Geometry).IsAssignableFrom(t) && instance is not null
method.ReturnType,
arguments[1].TypeMapping),

nameof(NpgsqlNetTopologySuiteDbFunctionsExtensions.IntersectsBbox) => _sqlExpressionFactory.MakePostgresBinary(
PgExpressionType.Overlaps,
arguments[1],
arguments[2]),

nameof(NpgsqlNetTopologySuiteDbFunctionsExtensions.DistanceKnn) => _sqlExpressionFactory.MakePostgresBinary(
PgExpressionType.Distance,
arguments[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql(TestEnvironment.DefaultConnection);

public DbSet<Blog> Blogs { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,32 @@ public override async Task Intersection(bool async)
""");
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public async Task IntersectsBbox(bool async)
{
var polygon = Fixture.GeometryFactory.CreatePolygon([new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(0, 1), new Coordinate(0, 0)]);

await AssertQuery(
async,
ss => ss.Set<PolygonEntity>().Select(e => new { e.Id, IntersectsBbox = (bool?)EF.Functions.IntersectsBbox(e.Polygon, polygon) }),
ss => ss.Set<PolygonEntity>().Select(e => new { e.Id, IntersectsBbox = (e.Polygon == null ? (bool?)null : e.Polygon.EnvelopeInternal.Intersects(polygon.EnvelopeInternal)) }),
elementSorter: e => e.Id,
elementAsserter: (e, a) =>
{
Assert.Equal(e.Id, a.Id);
Assert.Equal(e.IntersectsBbox, a.IntersectsBbox);
});

AssertSql(
"""
@polygon='POLYGON ((0 0, 1 0, 0 1, 0 0))' (DbType = Object)

SELECT p."Id", p."Polygon" && @polygon AS "IntersectsBbox"
FROM "PolygonEntity" AS p
""");
}

public override async Task Intersects(bool async)
{
await base.Intersects(async);
Expand Down