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 support for getting filter columns for a parsed query #21

Merged
merged 4 commits into from
Jan 10, 2024

Conversation

lfittl
Copy link
Member

@lfittl lfittl commented May 30, 2023

This works the same as the "#filter_columns" method in the pg_query Ruby gem, and returns the table name (if present) and column name for every column that's referenced in a JOIN or WHERE clause.

To support this functionality, the nodes() and nodes_mut() functions gain a 4th value for each result item, indicating whether the current node can be considered a filter column. This is intended to be used when matching a ColumnRef node, to determine whether it is part of a WHERE/JOIN clause, or part of something else (e.g. target list, or ORDER BY, etc).

@lfittl lfittl requested review from seanlinsley and a team May 30, 2023 07:41
src/parse_result.rs Outdated Show resolved Hide resolved
tests/filter_column_tests.rs Outdated Show resolved Hide resolved
lfittl added 2 commits January 9, 2024 15:21
This works the same as the "#filter_columns" method in the pg_query Ruby
gem, and returns the table name (if present) and column name for every
column that's referenced in a JOIN or WHERE clause.

To support this functionality, the nodes() and nodes_mut() functions
gain a 4th value for each result item, indicating whether the current
node can be considered a filter column. This is intended to be used when
matching a ColumnRef node, to determine whether it is part of a WHERE/JOIN
clause, or part of something else (e.g. target list, or ORDER BY, etc).
@lfittl lfittl merged commit f2ea0d7 into main Jan 10, 2024
7 checks passed
@lfittl lfittl deleted the filter-columns branch January 10, 2024 00:29
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.

2 participants