submarcos / django-vectortiles

Mapbox VectorTiles for django, with PostGIS or Python
https://django-vectortiles.readthedocs.io
MIT License
38 stars 11 forks source link

Correctly build SQL string with filtered date #5

Closed StefanBrand closed 3 years ago

StefanBrand commented 3 years ago

When filtering for dates, this happened:

django.db.utils.ProgrammingError: operator does not exist: date = integer
LINE 1: ...est_app_feature" WHERE ("test_app_feature"."date" = 2020-07-...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

The reason is that .format(features.query) calls the __str__ method of the sql.Query, which produces unparsed output.

https://github.com/submarcos/django-vectortiles/blob/70514bef851e955726e0b5db49c06c3e177045dd/vectortiles/postgis/mixins.py#L32

This PR aims to fix this issue, by correctly passing the params to the cursor.execute() function.

codecov[bot] commented 3 years ago

Codecov Report

Merging #5 (b31a150) into master (70514be) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #5   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          145       146    +1     
=========================================
+ Hits           145       146    +1     
Impacted Files Coverage Δ
vectortiles/postgis/mixins.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 70514be...b31a150. Read the comment docs.

submarcos commented 3 years ago

Thank you for your fix and your contrib. I hope to fix all these problems in future by writing a real custom SubQuery or Aggregate for this. #1 . Il will add many tests on each database type.

StefanBrand commented 3 years ago

Thank you for merging so quickly! I'm looking forward to the new release so that I can easily use it in our project. :slightly_smiling_face: