aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sql_algebra/relations
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2007-12-30 13:22:31 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2007-12-30 13:22:31 -0800
commitf9cc8bba39b1deb6b3f70cecb96beaf988054915 (patch)
treede8bc118ee34c5870f0175c05298f9ab39250617 /lib/sql_algebra/relations
parent960bbcb3ce4a82cf4f031d1c6682ce4c1a04474d (diff)
downloadrails-f9cc8bba39b1deb6b3f70cecb96beaf988054915.tar.gz
rails-f9cc8bba39b1deb6b3f70cecb96beaf988054915.tar.bz2
rails-f9cc8bba39b1deb6b3f70cecb96beaf988054915.zip
various
Diffstat (limited to 'lib/sql_algebra/relations')
-rw-r--r--lib/sql_algebra/relations/order_relation.rb11
-rw-r--r--lib/sql_algebra/relations/predicates/binary_predicate.rb12
-rw-r--r--lib/sql_algebra/relations/predicates/equality_predicate.rb7
-rw-r--r--lib/sql_algebra/relations/predicates/greater_than_or_equal_to_predicate.rb2
-rw-r--r--lib/sql_algebra/relations/predicates/greater_than_predicate.rb2
-rw-r--r--lib/sql_algebra/relations/predicates/less_than_or_equal_to_predicate.rb2
-rw-r--r--lib/sql_algebra/relations/predicates/less_than_predicate.rb2
-rw-r--r--lib/sql_algebra/relations/predicates/match_predicate.rb7
-rw-r--r--lib/sql_algebra/relations/predicates/predicate.rb5
-rw-r--r--lib/sql_algebra/relations/predicates/range_inclusion_predicate.rb0
-rw-r--r--lib/sql_algebra/relations/predicates/relation_inclusion_predicate.rb11
-rw-r--r--lib/sql_algebra/relations/projection_relation.rb11
-rw-r--r--lib/sql_algebra/relations/range_relation.rb11
-rw-r--r--lib/sql_algebra/relations/selection_relation.rb12
14 files changed, 45 insertions, 50 deletions
diff --git a/lib/sql_algebra/relations/order_relation.rb b/lib/sql_algebra/relations/order_relation.rb
new file mode 100644
index 0000000000..8d07c58d64
--- /dev/null
+++ b/lib/sql_algebra/relations/order_relation.rb
@@ -0,0 +1,11 @@
+class OrderRelation < Relation
+ attr_reader :relation, :attributes
+
+ def initialize(relation, *attributes)
+ @relation, @attributes = relation, attributes
+ end
+
+ def ==(other)
+ relation == other.relation and attributes.eql?(other.attributes)
+ end
+end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/binary_predicate.rb b/lib/sql_algebra/relations/predicates/binary_predicate.rb
deleted file mode 100644
index d7f4cb20e7..0000000000
--- a/lib/sql_algebra/relations/predicates/binary_predicate.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class BinaryPredicate < Predicate
- attr_reader :attribute1, :attribute2
-
- def initialize(attribute1, attribute2)
- @attribute1, @attribute2 = attribute1, attribute2
- end
-
- def ==(other)
- super and
- (attribute1.eql?(other.attribute1) and attribute2.eql?(other.attribute2))
- end
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/equality_predicate.rb b/lib/sql_algebra/relations/predicates/equality_predicate.rb
deleted file mode 100644
index 2d206e6c12..0000000000
--- a/lib/sql_algebra/relations/predicates/equality_predicate.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class EqualityPredicate < BinaryPredicate
- def ==(other)
- self.class == other.class and
- ((attribute1.eql?(other.attribute1) and attribute2.eql?(other.attribute2)) or
- (attribute1.eql?(other.attribute2) and attribute2.eql?(other.attribute1)))
- end
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/greater_than_or_equal_to_predicate.rb b/lib/sql_algebra/relations/predicates/greater_than_or_equal_to_predicate.rb
deleted file mode 100644
index 49127c312c..0000000000
--- a/lib/sql_algebra/relations/predicates/greater_than_or_equal_to_predicate.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class GreaterThanOrEqualToPredicate < BinaryPredicate
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/greater_than_predicate.rb b/lib/sql_algebra/relations/predicates/greater_than_predicate.rb
deleted file mode 100644
index 03aecaed62..0000000000
--- a/lib/sql_algebra/relations/predicates/greater_than_predicate.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class GreaterThanPredicate < BinaryPredicate
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/less_than_or_equal_to_predicate.rb b/lib/sql_algebra/relations/predicates/less_than_or_equal_to_predicate.rb
deleted file mode 100644
index fee6ea7f35..0000000000
--- a/lib/sql_algebra/relations/predicates/less_than_or_equal_to_predicate.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class LessThanOrEqualToPredicate < BinaryPredicate
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/less_than_predicate.rb b/lib/sql_algebra/relations/predicates/less_than_predicate.rb
deleted file mode 100644
index 03cbdcf000..0000000000
--- a/lib/sql_algebra/relations/predicates/less_than_predicate.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class LessThanPredicate < BinaryPredicate
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/match_predicate.rb b/lib/sql_algebra/relations/predicates/match_predicate.rb
deleted file mode 100644
index 90a13090d4..0000000000
--- a/lib/sql_algebra/relations/predicates/match_predicate.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class MatchPredicate < Predicate
- attr_reader :attribute, :regexp
-
- def initialize(attribute, regexp)
- @attribute, @regexp = attribute, regexp
- end
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/predicate.rb b/lib/sql_algebra/relations/predicates/predicate.rb
deleted file mode 100644
index 4c395a3fdc..0000000000
--- a/lib/sql_algebra/relations/predicates/predicate.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class Predicate
- def ==(other)
- self.class == other.class
- end
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/predicates/range_inclusion_predicate.rb b/lib/sql_algebra/relations/predicates/range_inclusion_predicate.rb
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/sql_algebra/relations/predicates/range_inclusion_predicate.rb
+++ /dev/null
diff --git a/lib/sql_algebra/relations/predicates/relation_inclusion_predicate.rb b/lib/sql_algebra/relations/predicates/relation_inclusion_predicate.rb
deleted file mode 100644
index 5881a85d99..0000000000
--- a/lib/sql_algebra/relations/predicates/relation_inclusion_predicate.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class RelationInclusionPredicate < Predicate
- attr_reader :attribute, :relation
-
- def initialize(attribute, relation)
- @attribute, @relation = attribute, relation
- end
-
- def ==(other)
- super and attribute == other.attribute and relation == other.relation
- end
-end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/projection_relation.rb b/lib/sql_algebra/relations/projection_relation.rb
new file mode 100644
index 0000000000..caebfc1b62
--- /dev/null
+++ b/lib/sql_algebra/relations/projection_relation.rb
@@ -0,0 +1,11 @@
+class ProjectionRelation < Relation
+ attr_reader :relation, :attributes
+
+ def initialize(relation, *attributes)
+ @relation, @attributes = relation, attributes
+ end
+
+ def ==(other)
+ relation == other.relation and attributes.eql?(other.attributes)
+ end
+end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/range_relation.rb b/lib/sql_algebra/relations/range_relation.rb
new file mode 100644
index 0000000000..fd7e2898fa
--- /dev/null
+++ b/lib/sql_algebra/relations/range_relation.rb
@@ -0,0 +1,11 @@
+class RangeRelation < Relation
+ attr_reader :relation, :range
+
+ def initialize(relation, range)
+ @relation, @range = relation, range
+ end
+
+ def ==(other)
+ relation == other.relation and range == other.range
+ end
+end \ No newline at end of file
diff --git a/lib/sql_algebra/relations/selection_relation.rb b/lib/sql_algebra/relations/selection_relation.rb
new file mode 100644
index 0000000000..5654d8de31
--- /dev/null
+++ b/lib/sql_algebra/relations/selection_relation.rb
@@ -0,0 +1,12 @@
+class SelectionRelation < Relation
+ attr_reader :relation, :predicate
+
+ def initialize(relation, *predicates)
+ @predicate = predicates.shift
+ @relation = predicates.empty?? relation : SelectionRelation.new(relation, *predicates)
+ end
+
+ def ==(other)
+ relation == other.relation and predicate == other.predicate
+ end
+end \ No newline at end of file