Opened 13 years ago
Last modified 11 years ago
#17018 new Bug
LayerMapping - entries skipped when ForeignKey field has related model missing and null = True
Reported by: | Glen Robertson | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | 1.3 |
Severity: | Normal | Keywords: | geodjango, layermapping |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
The LayerMapping utility will skip entries for a model that has missing foreign key entries when the foreign key field has null=True in it's configuration.
It would be better to add these entries and set the model's foreign key value to None when the foreign key doesn't exist.
Attachments (7)
Change History (12)
by , 13 years ago
Attachment: | layermapping.patch added |
---|
comment:1 by , 13 years ago
Summary: | LayerMapping - entry skipped when ForeignKey field has related model missing and null = True → LayerMapping - entries skipped when ForeignKey field has related model missing and null = True |
---|
comment:2 by , 13 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
by , 13 years ago
Attachment: | counties_null_state.dbf added |
---|
shapefile dbf for tests, put in django/contrib/gis/tests/data/counties
by , 13 years ago
Attachment: | counties_null_state.shx added |
---|
shapefile shx for tests, put in django/contrib/gis/tests/data/counties
by , 13 years ago
Attachment: | counties_null_state.shp added |
---|
shapefile shp for tests, put in django/contrib/gis/tests/data/counties
comment:3 by , 13 years ago
Owner: | changed from | to
---|
As above I have added attachments for an updated patch that includes unit tests.
They require the 3 files counties_null_state.* in the django/contrib/gis/tests/data/counties directory
I also modified the original patch to do the checking in the verify_fk method.
Cheers,
Glen
comment:4 by , 13 years ago
Needs tests: | unset |
---|---|
Owner: | changed from | to
Patch needs improvement: | unset |
comment:5 by , 11 years ago
Patch needs improvement: | set |
---|
Two minor remarks:
except
clause, you can simply useraise
to raise the current exception.