未验证 提交 328ed171 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #38689 from yashLadha/refactor/arel_fetch_attribute

refactor: arel fetch_attribute to get the atrribute node from binary module.
......@@ -51,11 +51,8 @@ def self.fetch_attribute(value, &block) # :nodoc:
when Arel::Nodes::Between, Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality,
Arel::Nodes::NotEqual, Arel::Nodes::LessThan, Arel::Nodes::LessThanOrEqual,
Arel::Nodes::GreaterThan, Arel::Nodes::GreaterThanOrEqual
if value.left.is_a?(Arel::Attributes::Attribute)
yield value.left
elsif value.right.is_a?(Arel::Attributes::Attribute)
yield value.right
end
attribute_value = value.detect_attribute
yield attribute_value if attribute_value
when Arel::Nodes::Or
fetch_attribute(value.left, &block) && fetch_attribute(value.right, &block)
when Arel::Nodes::Grouping
......
......@@ -11,6 +11,14 @@ def initialize(left, right)
@right = right
end
def detect_attribute
if self.left.is_a?(Arel::Attributes::Attribute)
self.left
elsif self.right.is_a?(Arel::Attributes::Attribute)
self.right
end
end
def initialize_copy(other)
super
@left = @left.clone if @left
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册