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

Fix matching view's real column name #1133

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

aidanharan
Copy link
Contributor

@aidanharan aidanharan commented Nov 8, 2023

Fix for issue #1131

The regex to match a view column to table column name was too vague, which could cause a similarly named view column to be matched.

The issue was found in v7.0.5.0 (containing #1126) but the issue was actually present in previous releases (eg: v7.0.4.0). The order that the view columns were declared affected whether the issue appeared or not.

For example if you had view declaration:

CREATE VIEW bug_tests AS SELECT id AS id, dt_field as dt, dt_fieldX as dt_x FROM bug_test_tables

And performed regex of CREATE\s+VIEW.*AS\s+SELECT.*\W([\w-]*)\s+AS\s+dt on it then you would get match:

  1. dt_fieldX

If you changed the view declaration so that dt_x is before dt:

CREATE VIEW bug_tests AS SELECT id AS id, dt_fieldX as dt_x, dt_field as dt FROM bug_test_tables

Then the same regex would match:

  1. dt_field

In the fixed I remove the CREATE VIEW ... AS SELECT ... clause to simplify the regex to match the column name followed by a non-word character.

@aidanharan aidanharan marked this pull request as ready for review November 8, 2023 12:07
@aidanharan aidanharan changed the title Fix for matching view's real column name Fix matching view's real column name Nov 8, 2023
@aidanharan aidanharan merged commit bbcfa82 into 7-0-stable Nov 8, 2023
6 checks passed
@aidanharan aidanharan deleted the views-fix-real-column-name branch November 8, 2023 12:19
aidanharan added a commit that referenced this pull request Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant