-
Notifications
You must be signed in to change notification settings - Fork 85
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
Correctly find nested tables in a subselect in a join condition #233
Correctly find nested tables in a subselect in a join condition #233
Conversation
lib/pg_query/parse.rb
Outdated
end | ||
end | ||
|
||
subselect_items.concat(join_expr_quals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work, but I'd appreciate someone more familiar with the code taking a look. It's possible I may be overlooking something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, I forgot that you can do that (putting subselects inside a JOIN condition) - thanks for the contribution!
@@ -273,6 +273,7 @@ def load_objects! # rubocop:disable Metrics/CyclomaticComplexity | |||
when :join_expr | |||
from_clause_items << { item: next_item[:item].join_expr.larg, type: next_item[:type] } | |||
from_clause_items << { item: next_item[:item].join_expr.rarg, type: next_item[:type] } | |||
subselect_items.concat << next_item[:item].join_expr.quals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I just realized we are missing a .to_ary
here (because of https://bugs.ruby-lang.org/issues/18140, per the comment on top of the function) -- I'll make a quick commit to adjust that
Expected behavior:
On
main
,baz
isn't being found. On my branch it is, as well as tables that are nested further inside of a join condition (see spec for a query with more nested join conditions and subqueries).