Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KML, CSV, Shapefile advanced search exports #103

Merged
merged 3 commits into from May 7, 2013
Merged

Fix KML, CSV, Shapefile advanced search exports #103

merged 3 commits into from May 7, 2013

Conversation

steventlamb
Copy link
Contributor

Fixes Github Issue #76

Previously exports were only working for basic searches and were
broken for most advanced search filters. They now work for all
advanced search filters. Tested on TreeZilla.

The problem:
The advanced search routine builds up queryset for several models
and exports the queryset.query (raw sql query) to ogr2ogr, which
reruns the queries and exports to the aforementioned formats. The
problem is that Django is mishandling type coercions for certain
database fields that are stored as textual representations of other
values. For example, we store native_status as a varchar, but its
value is usually restricted to "True" or "False", which was being
sent to the querybuilder as True or False, the boolean values. The
other known example is integer values stored as varchars.

The Solution:
After discussing the possibility of enabling type coercion at the
database level, it was decided that a localized changed would be
safer than a global one. So, adding some functions that sanitize
the raw SQL that goes to ogr2ogr to be the correct textual string
instead of the represented value.

Fixes Github Issue #76

Previously exports were only working for basic searches and were
broken for most advanced search filters. They now work for all
advanced search filters. Tested on TreeZilla.

The problem:
The advanced search routine builds up queryset for several models
and exports the queryset.query (raw sql query) to ogr2ogr, which
reruns the queries and exports to the aforementioned formats. The
problem is that Django is mishandling type coercions for certain
database fields that are stored as textual representations of other
values. For example, we store native_status as a varchar, but its
value is usually restricted to "True" or "False", which was being
sent to the querybuilder as True or False, the boolean values. The
other known example is integer values stored as varchars.

The Solution:
After discussing the possibility of enabling type coercion at the
database level, it was decided that a localized changed would be
safer than a global one. So, adding some functions that sanitize
the raw SQL that goes to ogr2ogr to be the correct textual string
instead of the represented value.
@@ -0,0 +1,92 @@
#
# This module contains functions and views to be used for
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just functions

@ahinz ahinz mentioned this pull request May 6, 2013
Steve Lamb added 2 commits May 7, 2013 15:35
Modify tests to use more instructive test data
steventlamb pushed a commit that referenced this pull request May 7, 2013
Fix KML, CSV, Shapefile advanced search exports
@steventlamb steventlamb merged commit ac434dc into OpenTreeMap:v1.3 May 7, 2013
@steventlamb steventlamb deleted the bug/fix_exports branch May 7, 2013 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant