Opened 8 years ago
Closed 8 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:1 by , 8 years ago
comment:2 by , 8 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Patch needs improvement: | set |
| Triage Stage: | Unreviewed → Accepted |
The patch needs adjustments as some tests are failing and some additional regression tests would be required for the handling of None arguments.
comment:4 by , 8 years ago
| Needs tests: | unset |
|---|---|
| Patch needs improvement: | unset |
comment:5 by , 8 years ago
| Patch needs improvement: | set |
|---|
PR: https://github.com/django/django/pull/8722