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

Match literal underscore in LIKE pattern "pg\_%" #9

Merged

Conversation

dodobas
Copy link

@dodobas dodobas commented Nov 24, 2024

_ matches single character in LIKE pattern matching, so a pattern LIKE 'pg_%' would match anything that starts with pg and is at least
3 characters long, like 'pg1'.

To correct matching pattern and only match pg_% we need to escape literal underscore pg\_%

@laurenz
Copy link
Contributor

laurenz commented Nov 25, 2024

Yes, that is a bug, and your fix is correct.

Instead of creating a pg_permissions--1.4.sql, please create a pg_permissions--1.3-1.4.sql. That will be much shorter.

Also, I think that the regression tests could be shorter. I think that it is good enough to test a table, and we don't need to verify that the improved pattern also works for a schema containing a sequence as well.

@laurenz laurenz added the bug Something isn't working label Nov 25, 2024
`_` matches single character in LIKE pattern matching, so a pattern
`LIKE 'pg_%'` would match anything that starts with `pg` and is at least
 3 characters long, like 'pg1'.

To correct matching pattern and only match `pg_%` we need to
escape literal underscore `pg\_%`
@dodobas dodobas force-pushed the fix-LIKE-pattern-matching branch from 7062cee to 7190951 Compare November 26, 2024 09:06
@dodobas
Copy link
Author

dodobas commented Nov 26, 2024

Thank you for the input, I've updated the PR.

I've used create or replace view which keeps permissions of the old views

@laurenz laurenz merged commit 7190951 into cybertec-postgresql:master Nov 26, 2024
@laurenz
Copy link
Contributor

laurenz commented Nov 26, 2024

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants