diff options
Diffstat (limited to 'lib/sql_algebra')
-rw-r--r-- | lib/sql_algebra/relations/join_operation.rb | 2 | ||||
-rw-r--r-- | lib/sql_algebra/relations/relation.rb | 29 |
2 files changed, 26 insertions, 5 deletions
diff --git a/lib/sql_algebra/relations/join_operation.rb b/lib/sql_algebra/relations/join_operation.rb index dab8e9e6bd..2b4548a041 100644 --- a/lib/sql_algebra/relations/join_operation.rb +++ b/lib/sql_algebra/relations/join_operation.rb @@ -6,7 +6,7 @@ class JoinOperation end def on(*predicates) - JoinRelation.new(relation1, relation2, *predicates) + relation_class.new(relation1, relation2, *predicates) end def ==(other) diff --git a/lib/sql_algebra/relations/relation.rb b/lib/sql_algebra/relations/relation.rb index f1f8fc5884..bd812b368d 100644 --- a/lib/sql_algebra/relations/relation.rb +++ b/lib/sql_algebra/relations/relation.rb @@ -1,13 +1,34 @@ class Relation - def *(other) - JoinOperation.new(self, other) + def <=>(other) + InnerJoinOperation.new(self, other) end - def [](attribute_name) - Attribute.new(self, attribute_name) + def <<(other) + LeftOuterJoinOperation.new(self, other) + end + + def [](index) + case index + when Symbol + Attribute.new(self, index) + when Range + RangeRelation.new(self, index) + end end def include?(attribute) RelationInclusionPredicate.new(attribute, self) end + + def select(*predicates) + SelectionRelation.new(self, *predicates) + end + + def project(*attributes) + ProjectionRelation.new(self, *attributes) + end + + def order(*attributes) + OrderRelation.new(self, *attributes) + end end
\ No newline at end of file |