sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

Compute TokenList.value dynamically (v2)

Open living180 opened this issue 2 years ago • 4 comments

This PR supersedes #623. The meat of the PR is the same: fix the remaining portion of issue #621 by making TokenList.value a dynamically-computed property rather than an attribute. This avoids the quadratic runtime behavior that occurred due to recomputing TokenList.value each time TokenList.group_tokens() was called with extend=True.

The previous PR #623 had some rather awkward hacks related to stripping comments, but I found that I could avoid those by simply tweaking the comment stripping process to strip comments from a token list before stripping any sublists, making this PR much simpler.

living180 avatar Mar 28 '23 13:03 living180

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 :tada:

Comparison is base (fc76056) 96.95% compared to head (d2ab15c) 96.97%.

:exclamation: Current head d2ab15c differs from pull request most recent head ff4f391. Consider uploading reports for the commit ff4f391 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #710      +/-   ##
==========================================
+ Coverage   96.95%   96.97%   +0.01%     
==========================================
  Files          20       20              
  Lines        1545     1555      +10     
==========================================
+ Hits         1498     1508      +10     
  Misses         47       47              
Impacted Files Coverage Δ
sqlparse/filters/others.py 98.79% <100.00%> (ø)
sqlparse/sql.py 97.68% <100.00%> (+0.06%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Mar 28 '23 13:03 codecov[bot]

This is just the fix I need. Ran into some problems with parsing SQL with ~50k ID IN clauses, which with 0.4.4 takes a bit over 6 minutes to parse and with this patch only takes 6 seconds !!!

sdether avatar Aug 11 '23 00:08 sdether

any progress here?

rumbin avatar Nov 20 '23 11:11 rumbin