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

Add option --remove_pg_catalog_from_functions #90

Merged
merged 7 commits into from
Sep 18, 2021
Merged

Add option --remove_pg_catalog_from_functions #90

merged 7 commits into from
Sep 18, 2021

Conversation

borisz
Copy link
Contributor

@borisz borisz commented Sep 11, 2021

The new option removes the pg_catalog schema before function calls.
These may occur when PG replaces the desired function with an
adequate other function.

# output without the new option

❯ pgpp -m 100 -S "select substring('123',2,3), btrim('xxx'), trim('xxx'), POSITION('hour' in trim(substring('xyz hour ',1,6)))"
SELECT pg_catalog.substring('123', 2, 3)
     , btrim('xxx')
     , pg_catalog.btrim('xxx')
     , pg_catalog.position(pg_catalog.btrim(pg_catalog.substring('xyz hour ', 1, 6)), 'hour')

# new output with -F

❯ pgpp -F -m 100 -S "select substring('123',2,3), btrim('xxx'), trim('xxx'), POSITION('hour' in trim(substring('xyz hour ',1,6)))"
SELECT substring('123', 2, 3)
     , btrim('xxx')
     , btrim('xxx')
     , pg_catalog.position(btrim(substring('xyz hour ', 1, 6)), 'hour')

The new option removes the pg_catalog schema before function calls.
These may occur when PG replaces the desired function with an
adequate other function.
Unfortunately position('a', 'b') is not directly callable.
The reason is the parameters flipped compared to
position('b' in 'a').

Possible is
position('b' in 'a')
pg_catalog.position('a', 'b')
strpos('a', 'b')
pg_catalog.strpos('a', 'b')
pglast/__main__.py Outdated Show resolved Hide resolved
pglast/stream.py Outdated Show resolved Hide resolved
Rename option to remove-pg_catalog-from-functions and move it closer to other named options
@borisz borisz requested a review from lelit September 13, 2021 19:50
tests/test_cli.py Outdated Show resolved Hide resolved
@borisz borisz requested a review from lelit September 14, 2021 08:00
@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2021

Codecov Report

Merging #90 (881854a) into v3 (7539620) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##               v3      #90   +/-   ##
=======================================
  Coverage   99.51%   99.51%           
=======================================
  Files          23       23           
  Lines        6344     6351    +7     
=======================================
+ Hits         6313     6320    +7     
  Misses         31       31           
Impacted Files Coverage Δ
pglast/__main__.py 97.95% <100.00%> (+0.04%) ⬆️
pglast/stream.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 7539620...881854a. Read the comment docs.

@lelit lelit merged commit ef5aa48 into lelit:v3 Sep 18, 2021
@lelit
Copy link
Owner

lelit commented Sep 18, 2021

Thank you Boris, this is now merged into v3.

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.

3 participants