Opened 7 years ago

Closed 7 years ago

#28380 closed Bug (fixed)

Wrong handling of NULL values in spatialite geometry comparison functions

Reported by: Fabian Schindler Owned by: nobody
Component: GIS Version: 1.11
Severity: Normal Keywords: spatialite geometry
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

For several geometry comparison functions (e.g: ST_Intersects, ST_Equals, ...) the spatialite documentation states that

The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and –1 for UNKNOWN corresponding to a function invocation on NULL arguments.

Unfortunately, the -1 value is not handled separately, so (e.g:) intersection filters will include database records where the geometry is NULL.

A fix would be to change the lookup from:

...
WHERE Intersects("modelname"."fieldname", GeomFromText('...',4326));

to

...
WHERE Intersects("modelname"."fieldname", GeomFromText('...',4326)) > 0;

Change History (6)

comment:2 by Simon Charette, 7 years ago

Has patch: set
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

The patch needs adjustments as some tests are failing and some additional regression tests would be required for the handling of None arguments.

comment:3 by Fabian Schindler, 7 years ago

New PR (old one was closed because of wrong base)

comment:4 by Tim Graham, 7 years ago

Needs tests: unset
Patch needs improvement: unset

comment:5 by Tim Graham, 7 years ago

Patch needs improvement: set

comment:6 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In da0fb5b1:

Fixed #28380 -- Excluded null geometries in SpatiaLite geometry lookups.

Note: See TracTickets for help on using tickets.
Back to Top