mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
relation inclusion operator
This commit is contained in:
parent
c1e223f8a9
commit
c2cbe7bb27
5 changed files with 25 additions and 5 deletions
|
@ -40,15 +40,31 @@ module ActiveRelation
|
|||
end
|
||||
|
||||
class GreaterThanOrEqualTo < Binary
|
||||
protected
|
||||
def predicate_sql
|
||||
'>='
|
||||
end
|
||||
end
|
||||
|
||||
class GreaterThan < Binary
|
||||
protected
|
||||
def predicate_sql
|
||||
'>'
|
||||
end
|
||||
end
|
||||
|
||||
class LessThanOrEqualTo < Binary
|
||||
protected
|
||||
def predicate_sql
|
||||
'<='
|
||||
end
|
||||
end
|
||||
|
||||
class LessThan < Binary
|
||||
protected
|
||||
def predicate_sql
|
||||
'<'
|
||||
end
|
||||
end
|
||||
|
||||
class Match < Base
|
||||
|
@ -69,6 +85,10 @@ module ActiveRelation
|
|||
def ==(other)
|
||||
super and attribute == other.attribute and relation == other.relation
|
||||
end
|
||||
|
||||
def to_sql(options = {})
|
||||
"#{attribute.to_sql} IN (#{relation.to_sql})"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
module ActiveRelation
|
||||
module Relations
|
||||
class Order < Compound
|
||||
attr_reader :relation, :orders
|
||||
attr_reader :orders
|
||||
|
||||
def initialize(relation, *orders)
|
||||
@relation, @orders = relation, orders
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
module ActiveRelation
|
||||
module Relations
|
||||
class Projection < Compound
|
||||
attr_reader :relation, :attributes
|
||||
attr_reader :attributes
|
||||
|
||||
def initialize(relation, *attributes)
|
||||
@relation, @attributes = relation, attributes
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
relation == other.relation and attributes == other.attributes
|
||||
self.class == other.class and relation == other.relation and attributes == other.attributes
|
||||
end
|
||||
|
||||
def qualify
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module ActiveRelation
|
||||
module Relations
|
||||
class Rename < Compound
|
||||
attr_reader :relation, :schmattribute, :alias
|
||||
attr_reader :schmattribute, :alias
|
||||
|
||||
def initialize(relation, renames)
|
||||
@schmattribute, @alias = renames.shift
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module ActiveRelation
|
||||
module Relations
|
||||
class Selection < Compound
|
||||
attr_reader :relation, :predicate
|
||||
attr_reader :predicate
|
||||
|
||||
def initialize(relation, *predicates)
|
||||
@predicate = predicates.shift
|
||||
|
|
Loading…
Reference in a new issue