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

Correctly build SQL string with filtered date #5

Merged
merged 1 commit into from
Feb 12, 2021

Conversation

StefanBrand
Copy link
Contributor

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.

cursor.execute("SELECT ST_ASMVT(subquery.*, %s, %s, %s) FROM ({}) as subquery".format(features.query),

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

@codecov
Copy link

codecov bot commented Feb 12, 2021

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
Copy link
Owner

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.

@submarcos submarcos merged commit ddfafe8 into submarcos:master Feb 12, 2021
@StefanBrand StefanBrand deleted the sql-string-with-date branch February 12, 2021 15:51
@StefanBrand
Copy link
Contributor Author

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

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.

2 participants