From edc721806a8ed48534789e086d091d70a53e3f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Siffert?= Date: Fri, 6 Nov 2026 17:09:17 +0000 Subject: [PATCH] [FIX] base_geoengine: pass the SRID in the geo_equal literal get_geo_equal_sql built the compared geometry with ST_GeomFromText(%s), without an SRID. PostGIS then creates the literal with SRID 0, which is never equal to a column stored with the field's SRID, so a direct geo_equal domain always returned an empty recordset, silently. Pass the field SRID as the other spatial operators already do in _get_postgis_comp_sql, and add a regression test for the direct (non-dict) form of geo_equal, which was not covered. Fixes #471 --- base_geoengine/geo_operators.py | 3 ++- base_geoengine/tests/test_model.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/base_geoengine/geo_operators.py b/base_geoengine/geo_operators.py index d3078e1ac..367a89b66 100644 --- a/base_geoengine/geo_operators.py +++ b/base_geoengine/geo_operators.py @@ -48,8 +48,9 @@ def get_geo_equal_sql( (used for equality comparison) """ base = self.geo_field.entry_to_shape(value, same_type=False) - compare_to = "ST_GeomFromText(%s)" + compare_to = "ST_GeomFromText(%s, %s)" params.append(base.wkt) + params.append(self.geo_field.srid) return " {}.{} = {}".format(table, col, compare_to) def get_geo_intersect_sql(self, table, col, value, params): diff --git a/base_geoengine/tests/test_model.py b/base_geoengine/tests/test_model.py index 12faceb2a..093ac5c0c 100644 --- a/base_geoengine/tests/test_model.py +++ b/base_geoengine/tests/test_model.py @@ -526,6 +526,15 @@ def test_search_equals(self): self.assertEqual(1, len(result)) self.assertEqual(result.city, "Mollens (VD))") + def test_search_equals_direct_value(self): + """geo_equal with a direct geometry value must match (SRID in literal)""" + zip_item = self.env["dummy.zip"].search([("name", "=", "1146")]) + self.assertEqual(1, len(zip_item)) + + result = zip_item.search([("the_geom", "geo_equal", zip_item.the_geom)]) + + self.assertEqual(zip_item, result) + def test_search_touch_polygon(self): zip_item = self.env["dummy.zip"]