Skip to content

Avoid stripping additional characters from GIS SQL params. #1544

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

Closed
wants to merge 3 commits into from
Closed

Avoid stripping additional characters from GIS SQL params. #1544

wants to merge 3 commits into from

Conversation

tim-schilling
Copy link
Member

If the param lead or ended with characters identified in the strip
calls, those characters would also be removed. Using split will
retain all of the characters in between the given strings.

When we drop support for < 3.9, we can switch to
the removeprefix and removesuffix functions.

Fixes #1543

This should add a test case that confirms the fix for 1543, but I'm unsure of what that would look like. If we think we absolutely need a test case for it, then perhaps we move it to panels/sql/utils.py so it can be in a unit test rather than an integration test.

@codecov
Copy link

codecov bot commented Dec 14, 2021

Codecov Report

Merging #1544 (68f8a1c) into main (4adfcc1) will increase coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1544      +/-   ##
==========================================
+ Coverage   85.75%   85.91%   +0.15%     
==========================================
  Files          36       36              
  Lines        1889     1889              
  Branches      313      313              
==========================================
+ Hits         1620     1623       +3     
+ Misses        190      187       -3     
  Partials       79       79              
Impacted Files Coverage Δ
debug_toolbar/panels/sql/tracking.py 88.80% <100.00%> (ø)
debug_toolbar/panels/profiling.py 88.54% <0.00%> (+3.12%) ⬆️

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 4adfcc1...68f8a1c. Read the comment docs.

@tim-schilling
Copy link
Member Author

Ah, this needs to not run when it's not a GIS sql param.

@matthiask
Copy link
Member

Now that I read the code again I'm really unsure. We're modifying the SQL which is being executed instead of only logging it and maybe fixing it later when trying to analyze/explain it.

Is there a good reason for modifying the params list before calling cursor.execute, cursor.callproc etc. at all?

@tim-schilling
Copy link
Member Author

I'm not sure. Even though the tests indicate we test for postgis, it's not used. I'm working through setting it up locally to see if the tests pass.

If the param lead or ended with characters identified in the strip
calls, those characters would also be removed. Using split will
retain all of the characters inbetween the given strings.

When we drop support for < 3.9, we can switch to
the removeprefix and removesuffix functions.

Fixes #1543
Include mention in the docs about how to configure the user
locally to install PostgreSQL extensions.
@tim-schilling
Copy link
Member Author

@matthiask I'm going to revert #1426. I don't think it ever covered the change and the test is broken.

@tim-schilling
Copy link
Member Author

Replaced by #1547

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.

Some String Has Truncated Before Model Save In Releases Version==3.2.3
2 participants