arel-compat 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. data/History.txt +25 -0
  2. data/README.markdown +182 -0
  3. data/lib/arel.rb +13 -0
  4. data/lib/arel/algebra.rb +10 -0
  5. data/lib/arel/algebra/attributes.rb +7 -0
  6. data/lib/arel/algebra/attributes/attribute.rb +270 -0
  7. data/lib/arel/algebra/attributes/boolean.rb +21 -0
  8. data/lib/arel/algebra/attributes/decimal.rb +9 -0
  9. data/lib/arel/algebra/attributes/float.rb +9 -0
  10. data/lib/arel/algebra/attributes/integer.rb +10 -0
  11. data/lib/arel/algebra/attributes/string.rb +10 -0
  12. data/lib/arel/algebra/attributes/time.rb +6 -0
  13. data/lib/arel/algebra/core_extensions.rb +4 -0
  14. data/lib/arel/algebra/core_extensions/class.rb +32 -0
  15. data/lib/arel/algebra/core_extensions/hash.rb +11 -0
  16. data/lib/arel/algebra/core_extensions/object.rb +30 -0
  17. data/lib/arel/algebra/core_extensions/symbol.rb +9 -0
  18. data/lib/arel/algebra/expression.rb +43 -0
  19. data/lib/arel/algebra/header.rb +67 -0
  20. data/lib/arel/algebra/ordering.rb +23 -0
  21. data/lib/arel/algebra/predicates.rb +190 -0
  22. data/lib/arel/algebra/relations.rb +17 -0
  23. data/lib/arel/algebra/relations/operations/alias.rb +7 -0
  24. data/lib/arel/algebra/relations/operations/from.rb +6 -0
  25. data/lib/arel/algebra/relations/operations/group.rb +12 -0
  26. data/lib/arel/algebra/relations/operations/having.rb +17 -0
  27. data/lib/arel/algebra/relations/operations/join.rb +69 -0
  28. data/lib/arel/algebra/relations/operations/lock.rb +12 -0
  29. data/lib/arel/algebra/relations/operations/order.rb +19 -0
  30. data/lib/arel/algebra/relations/operations/project.rb +20 -0
  31. data/lib/arel/algebra/relations/operations/skip.rb +7 -0
  32. data/lib/arel/algebra/relations/operations/take.rb +11 -0
  33. data/lib/arel/algebra/relations/operations/where.rb +17 -0
  34. data/lib/arel/algebra/relations/relation.rb +136 -0
  35. data/lib/arel/algebra/relations/row.rb +26 -0
  36. data/lib/arel/algebra/relations/utilities/compound.rb +54 -0
  37. data/lib/arel/algebra/relations/utilities/externalization.rb +24 -0
  38. data/lib/arel/algebra/relations/utilities/nil.rb +7 -0
  39. data/lib/arel/algebra/relations/writes.rb +36 -0
  40. data/lib/arel/algebra/value.rb +14 -0
  41. data/lib/arel/engines.rb +2 -0
  42. data/lib/arel/engines/memory.rb +4 -0
  43. data/lib/arel/engines/memory/engine.rb +16 -0
  44. data/lib/arel/engines/memory/predicates.rb +99 -0
  45. data/lib/arel/engines/memory/primitives.rb +27 -0
  46. data/lib/arel/engines/memory/relations.rb +5 -0
  47. data/lib/arel/engines/memory/relations/array.rb +35 -0
  48. data/lib/arel/engines/memory/relations/compound.rb +9 -0
  49. data/lib/arel/engines/memory/relations/operations.rb +67 -0
  50. data/lib/arel/engines/memory/relations/writes.rb +7 -0
  51. data/lib/arel/engines/sql.rb +8 -0
  52. data/lib/arel/engines/sql/attributes.rb +40 -0
  53. data/lib/arel/engines/sql/christener.rb +14 -0
  54. data/lib/arel/engines/sql/compilers/ibm_db_compiler.rb +48 -0
  55. data/lib/arel/engines/sql/compilers/mysql_compiler.rb +11 -0
  56. data/lib/arel/engines/sql/compilers/oracle_compiler.rb +95 -0
  57. data/lib/arel/engines/sql/compilers/postgresql_compiler.rb +42 -0
  58. data/lib/arel/engines/sql/compilers/sqlite_compiler.rb +9 -0
  59. data/lib/arel/engines/sql/core_extensions.rb +4 -0
  60. data/lib/arel/engines/sql/core_extensions/array.rb +24 -0
  61. data/lib/arel/engines/sql/core_extensions/nil_class.rb +15 -0
  62. data/lib/arel/engines/sql/core_extensions/object.rb +19 -0
  63. data/lib/arel/engines/sql/core_extensions/range.rb +19 -0
  64. data/lib/arel/engines/sql/engine.rb +55 -0
  65. data/lib/arel/engines/sql/formatters.rb +122 -0
  66. data/lib/arel/engines/sql/predicates.rb +103 -0
  67. data/lib/arel/engines/sql/primitives.rb +97 -0
  68. data/lib/arel/engines/sql/relations.rb +10 -0
  69. data/lib/arel/engines/sql/relations/compiler.rb +118 -0
  70. data/lib/arel/engines/sql/relations/operations/alias.rb +5 -0
  71. data/lib/arel/engines/sql/relations/operations/join.rb +33 -0
  72. data/lib/arel/engines/sql/relations/relation.rb +65 -0
  73. data/lib/arel/engines/sql/relations/table.rb +88 -0
  74. data/lib/arel/engines/sql/relations/utilities/compound.rb +10 -0
  75. data/lib/arel/engines/sql/relations/utilities/externalization.rb +14 -0
  76. data/lib/arel/engines/sql/relations/utilities/nil.rb +6 -0
  77. data/lib/arel/engines/sql/relations/utilities/recursion.rb +13 -0
  78. data/lib/arel/engines/sql/relations/writes.rb +19 -0
  79. data/lib/arel/session.rb +51 -0
  80. data/lib/arel/version.rb +3 -0
  81. data/spec/algebra/unit/predicates/binary_spec.rb +35 -0
  82. data/spec/algebra/unit/predicates/equality_spec.rb +29 -0
  83. data/spec/algebra/unit/predicates/in_spec.rb +12 -0
  84. data/spec/algebra/unit/primitives/attribute_spec.rb +181 -0
  85. data/spec/algebra/unit/primitives/expression_spec.rb +45 -0
  86. data/spec/algebra/unit/primitives/value_spec.rb +15 -0
  87. data/spec/algebra/unit/relations/alias_spec.rb +16 -0
  88. data/spec/algebra/unit/relations/delete_spec.rb +9 -0
  89. data/spec/algebra/unit/relations/group_spec.rb +10 -0
  90. data/spec/algebra/unit/relations/insert_spec.rb +9 -0
  91. data/spec/algebra/unit/relations/join_spec.rb +25 -0
  92. data/spec/algebra/unit/relations/order_spec.rb +21 -0
  93. data/spec/algebra/unit/relations/project_spec.rb +34 -0
  94. data/spec/algebra/unit/relations/relation_spec.rb +187 -0
  95. data/spec/algebra/unit/relations/skip_spec.rb +10 -0
  96. data/spec/algebra/unit/relations/table_spec.rb +38 -0
  97. data/spec/algebra/unit/relations/take_spec.rb +10 -0
  98. data/spec/algebra/unit/relations/update_spec.rb +9 -0
  99. data/spec/algebra/unit/relations/where_spec.rb +19 -0
  100. data/spec/algebra/unit/session/session_spec.rb +84 -0
  101. data/spec/attributes/boolean_spec.rb +57 -0
  102. data/spec/attributes/float_spec.rb +119 -0
  103. data/spec/attributes/header_spec.rb +42 -0
  104. data/spec/attributes/integer_spec.rb +119 -0
  105. data/spec/attributes/string_spec.rb +43 -0
  106. data/spec/attributes/time_spec.rb +24 -0
  107. data/spec/engines/memory/integration/joins/cross_engine_spec.rb +51 -0
  108. data/spec/engines/memory/unit/relations/array_spec.rb +32 -0
  109. data/spec/engines/memory/unit/relations/insert_spec.rb +28 -0
  110. data/spec/engines/memory/unit/relations/join_spec.rb +31 -0
  111. data/spec/engines/memory/unit/relations/order_spec.rb +27 -0
  112. data/spec/engines/memory/unit/relations/project_spec.rb +27 -0
  113. data/spec/engines/memory/unit/relations/skip_spec.rb +26 -0
  114. data/spec/engines/memory/unit/relations/take_spec.rb +26 -0
  115. data/spec/engines/memory/unit/relations/where_spec.rb +39 -0
  116. data/spec/engines/sql/integration/joins/with_adjacency_spec.rb +258 -0
  117. data/spec/engines/sql/integration/joins/with_aggregations_spec.rb +221 -0
  118. data/spec/engines/sql/integration/joins/with_compounds_spec.rb +137 -0
  119. data/spec/engines/sql/unit/engine_spec.rb +45 -0
  120. data/spec/engines/sql/unit/predicates/binary_spec.rb +140 -0
  121. data/spec/engines/sql/unit/predicates/equality_spec.rb +75 -0
  122. data/spec/engines/sql/unit/predicates/in_spec.rb +179 -0
  123. data/spec/engines/sql/unit/predicates/noteq_spec.rb +75 -0
  124. data/spec/engines/sql/unit/predicates/predicates_spec.rb +79 -0
  125. data/spec/engines/sql/unit/primitives/attribute_spec.rb +36 -0
  126. data/spec/engines/sql/unit/primitives/expression_spec.rb +28 -0
  127. data/spec/engines/sql/unit/primitives/literal_spec.rb +43 -0
  128. data/spec/engines/sql/unit/primitives/value_spec.rb +29 -0
  129. data/spec/engines/sql/unit/relations/alias_spec.rb +53 -0
  130. data/spec/engines/sql/unit/relations/delete_spec.rb +83 -0
  131. data/spec/engines/sql/unit/relations/from_spec.rb +64 -0
  132. data/spec/engines/sql/unit/relations/group_spec.rb +72 -0
  133. data/spec/engines/sql/unit/relations/having_spec.rb +78 -0
  134. data/spec/engines/sql/unit/relations/insert_spec.rb +143 -0
  135. data/spec/engines/sql/unit/relations/join_spec.rb +180 -0
  136. data/spec/engines/sql/unit/relations/lock_spec.rb +86 -0
  137. data/spec/engines/sql/unit/relations/order_spec.rb +161 -0
  138. data/spec/engines/sql/unit/relations/project_spec.rb +143 -0
  139. data/spec/engines/sql/unit/relations/skip_spec.rb +41 -0
  140. data/spec/engines/sql/unit/relations/table_spec.rb +129 -0
  141. data/spec/engines/sql/unit/relations/take_spec.rb +49 -0
  142. data/spec/engines/sql/unit/relations/update_spec.rb +203 -0
  143. data/spec/engines/sql/unit/relations/where_spec.rb +72 -0
  144. data/spec/relations/join_spec.rb +42 -0
  145. data/spec/relations/relation_spec.rb +31 -0
  146. data/spec/shared/relation_spec.rb +255 -0
  147. data/spec/spec_helper.rb +36 -0
  148. data/spec/support/check.rb +6 -0
  149. data/spec/support/connections/mysql_connection.rb +14 -0
  150. data/spec/support/connections/oracle_connection.rb +17 -0
  151. data/spec/support/connections/postgresql_connection.rb +13 -0
  152. data/spec/support/connections/sqlite3_connection.rb +24 -0
  153. data/spec/support/guards.rb +28 -0
  154. data/spec/support/matchers.rb +4 -0
  155. data/spec/support/matchers/be_like.rb +24 -0
  156. data/spec/support/matchers/disambiguate_attributes.rb +28 -0
  157. data/spec/support/matchers/hash_the_same_as.rb +26 -0
  158. data/spec/support/matchers/have_rows.rb +18 -0
  159. data/spec/support/model.rb +62 -0
  160. data/spec/support/schemas/mysql_schema.rb +26 -0
  161. data/spec/support/schemas/oracle_schema.rb +20 -0
  162. data/spec/support/schemas/postgresql_schema.rb +26 -0
  163. data/spec/support/schemas/sqlite3_schema.rb +26 -0
  164. metadata +258 -0
@@ -0,0 +1,21 @@
1
+ module Arel
2
+ module Attributes
3
+ class Boolean < Attribute
4
+ def type_cast(value)
5
+ case value
6
+ when true, false then value
7
+ # when nil then options[:allow_nil] ? nil : false
8
+ when nil then false
9
+ when 1 then true
10
+ when 0 then false
11
+ else
12
+ case value.to_s.downcase.strip
13
+ when 'true' then true
14
+ when 'false' then false
15
+ else raise typecast_error(value)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module Arel
2
+ module Attributes
3
+ class Decimal < Attribute
4
+ def type_cast(val)
5
+ type_cast_to_numeric(val, :to_d)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Arel
2
+ module Attributes
3
+ class Float < Attribute
4
+ def type_cast(val)
5
+ type_cast_to_numeric(val, :to_f)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Arel
2
+ module Attributes
3
+ class Integer < Attribute
4
+ def type_cast(val)
5
+ type_cast_to_numeric(val, :to_i)
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,10 @@
1
+ module Arel
2
+ module Attributes
3
+ class String < Attribute
4
+ def type_cast(value)
5
+ return unless value
6
+ value.to_s
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ module Arel
2
+ module Attributes
3
+ class Time < Attribute
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ require 'arel/algebra/core_extensions/object'
2
+ require 'arel/algebra/core_extensions/class'
3
+ require 'arel/algebra/core_extensions/symbol'
4
+ require 'arel/algebra/core_extensions/hash'
@@ -0,0 +1,32 @@
1
+ module Arel
2
+ module ClassExtensions
3
+ def attributes(*attrs)
4
+ @attributes = attrs
5
+ attr_reader(*attrs)
6
+ end
7
+
8
+ def deriving(*methods)
9
+ methods.each { |m| derive m }
10
+ end
11
+
12
+ def derive(method_name)
13
+ methods = {
14
+ :initialize => "
15
+ def #{method_name}(#{@attributes.join(',')})
16
+ #{@attributes.collect { |a| "@#{a} = #{a}" }.join("\n")}
17
+ end
18
+ ",
19
+ :== => "
20
+ def ==(other)
21
+ #{name} === other &&
22
+ #{@attributes.collect { |a| "@#{a} == other.#{a}" }.join(" &&\n")}
23
+ end
24
+ "
25
+ }
26
+ class_eval methods[method_name], __FILE__, __LINE__
27
+ end
28
+
29
+ Class.send(:include, self)
30
+ end
31
+ end
32
+
@@ -0,0 +1,11 @@
1
+ module Arel
2
+ module HashExtensions
3
+ def bind(relation)
4
+ inject({}) do |bound, (key, value)|
5
+ bound.merge(key.bind(relation) => value.bind(relation))
6
+ end
7
+ end
8
+
9
+ Hash.send(:include, self)
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ module Arel
2
+ module ObjectExtensions
3
+ def bind(relation)
4
+ Arel::Value.new(self, relation)
5
+ end
6
+
7
+ def find_correlate_in(relation)
8
+ bind(relation)
9
+ end
10
+
11
+ def let
12
+ yield(self)
13
+ end
14
+
15
+ # TODO remove this when ActiveSupport beta1 is out.
16
+ # Returns the object's singleton class.
17
+ def singleton_class
18
+ class << self
19
+ self
20
+ end
21
+ end unless respond_to?(:singleton_class)
22
+
23
+ # class_eval on an object acts like singleton_class_eval.
24
+ def class_eval(*args, &block)
25
+ singleton_class.class_eval(*args, &block)
26
+ end
27
+
28
+ Object.send(:include, self)
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ module Arel
2
+ module SymbolExtensions
3
+ def to_attribute(relation)
4
+ Arel::Attribute.new(relation, self)
5
+ end
6
+
7
+ Symbol.send(:include, self)
8
+ end
9
+ end
@@ -0,0 +1,43 @@
1
+ module Arel
2
+ class Expression < Attribute
3
+ attributes :attribute, :alias, :ancestor
4
+ deriving :==
5
+ delegate :relation, :to => :attribute
6
+ alias_method :name, :alias
7
+
8
+ def initialize(attribute, aliaz = nil, ancestor = nil)
9
+ @attribute, @alias, @ancestor = attribute, aliaz, ancestor
10
+ end
11
+
12
+ def aggregation?
13
+ true
14
+ end
15
+
16
+ def inspect
17
+ "<#{self.class.name} #{attribute.inspect}>"
18
+ end
19
+
20
+ module Transformations
21
+ def as(aliaz)
22
+ self.class.new(attribute, aliaz, self)
23
+ end
24
+
25
+ def bind(new_relation)
26
+ new_relation == relation ? self : self.class.new(attribute.bind(new_relation), @alias, self)
27
+ end
28
+
29
+ def to_attribute(relation)
30
+ Attribute.new(relation, @alias, :ancestor => self)
31
+ end
32
+ end
33
+ include Transformations
34
+ end
35
+
36
+ class Count < Expression; end
37
+ class Distinct < Expression; end
38
+ class Sum < Expression; end
39
+ class Maximum < Expression; end
40
+ class Minimum < Expression; end
41
+ class Average < Expression; end
42
+ end
43
+
@@ -0,0 +1,67 @@
1
+ module Arel
2
+ class Header
3
+ include Enumerable
4
+
5
+ def initialize(attrs = [])
6
+ @attributes = attrs.to_ary
7
+ @names = Hash.new do |h,k|
8
+ h[k] = @attributes.detect { |a| a.named?(k) }
9
+ end
10
+ end
11
+
12
+ def each(&block)
13
+ to_ary.each(&block)
14
+ self
15
+ end
16
+
17
+ def [](key)
18
+ case key
19
+ when String, Symbol then find_by_name(key)
20
+ when Attribute then find_by_attribute(key)
21
+ end
22
+ end
23
+
24
+ def ==(other)
25
+ to_set == other.to_set
26
+ end
27
+
28
+ def union(other)
29
+ new(to_ary | other)
30
+ end
31
+
32
+ alias | union
33
+
34
+ def to_ary
35
+ @attributes
36
+ end
37
+
38
+ def bind(relation)
39
+ Header.new(map { |a| a.bind(relation) })
40
+ end
41
+
42
+ # TMP
43
+ def index(i)
44
+ to_ary.index(i)
45
+ end
46
+
47
+ private
48
+
49
+ def new(attrs)
50
+ self.class.new(attrs)
51
+ end
52
+
53
+ def matching(attribute)
54
+ select { |a| !a.is_a?(Value) && a.root == attribute.root }
55
+ end
56
+
57
+ def find_by_name(name)
58
+ @names[name.to_sym]
59
+ end
60
+
61
+ def find_by_attribute(attr)
62
+ matching(attr).max do |a, b|
63
+ (a.original_attribute / attr) <=> (b.original_attribute / attr)
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,23 @@
1
+ module Arel
2
+ class Ordering
3
+ delegate :relation, :to => :attribute
4
+
5
+ def bind(relation)
6
+ self.class.new(attribute.bind(relation))
7
+ end
8
+
9
+ def to_ordering
10
+ self
11
+ end
12
+ end
13
+
14
+ class Ascending < Ordering
15
+ attributes :attribute
16
+ deriving :initialize, :==
17
+ end
18
+
19
+ class Descending < Ordering
20
+ attributes :attribute
21
+ deriving :initialize, :==
22
+ end
23
+ end
@@ -0,0 +1,190 @@
1
+ module Arel
2
+ module Predicates
3
+ class Predicate
4
+ def or(other_predicate)
5
+ Or.new(self, other_predicate)
6
+ end
7
+
8
+ def and(other_predicate)
9
+ And.new(self, other_predicate)
10
+ end
11
+
12
+ def complement
13
+ Not.new(self)
14
+ end
15
+
16
+ def not
17
+ self.complement
18
+ end
19
+ end
20
+
21
+ class Polyadic < Predicate
22
+ attributes :predicates
23
+
24
+ def initialize(*predicates)
25
+ @predicates = predicates
26
+ end
27
+
28
+ # Build a Polyadic predicate based on:
29
+ # * <tt>operator</tt> - The Predicate subclass that defines the type of operation
30
+ # (LessThan, Equality, etc)
31
+ # * <tt>operand1</tt> - The left-hand operand (normally an Arel::Attribute)
32
+ # * <tt>additional_operands</tt> - All possible right-hand operands
33
+ def self.build(operator, operand1, *additional_operands)
34
+ new(
35
+ *additional_operands.uniq.inject([]) do |predicates, operand|
36
+ predicates << operator.new(operand1, operand)
37
+ end
38
+ )
39
+ end
40
+
41
+ def ==(other)
42
+ same_elements?(@predicates, other.predicates)
43
+ end
44
+
45
+ def bind(relation)
46
+ self.class.new(
47
+ *predicates.map {|p| p.find_correlate_in(relation)}
48
+ )
49
+ end
50
+
51
+ private
52
+
53
+ def same_elements?(a1, a2)
54
+ [:select, :inject, :size].each do |m|
55
+ return false unless [a1, a2].each {|a| a.respond_to?(m) }
56
+ end
57
+ a1.inject({}) { |h,e| h[e] = a1.select { |i| i == e }.size; h } ==
58
+ a2.inject({}) { |h,e| h[e] = a2.select { |i| i == e }.size; h }
59
+ end
60
+ end
61
+
62
+ class Any < Polyadic
63
+ def complement
64
+ All.new(*predicates.map {|p| p.complement})
65
+ end
66
+ end
67
+
68
+ class All < Polyadic
69
+ def complement
70
+ Any.new(*predicates.map {|p| p.complement})
71
+ end
72
+ end
73
+
74
+ class Unary < Predicate
75
+ attributes :operand
76
+ deriving :initialize, :==
77
+
78
+ def bind(relation)
79
+ self.class.new(operand.find_correlate_in(relation))
80
+ end
81
+ end
82
+
83
+ class Not < Unary
84
+ def complement
85
+ operand
86
+ end
87
+ end
88
+
89
+ class Binary < Predicate
90
+ attributes :operand1, :operand2
91
+ deriving :initialize
92
+
93
+ def ==(other)
94
+ self.class === other and
95
+ @operand1 == other.operand1 and
96
+ @operand2 == other.operand2
97
+ end
98
+
99
+ def bind(relation)
100
+ self.class.new(operand1.find_correlate_in(relation), operand2.find_correlate_in(relation))
101
+ end
102
+ end
103
+
104
+ class CompoundPredicate < Binary; end
105
+
106
+ class And < CompoundPredicate
107
+ def complement
108
+ Or.new(operand1.complement, operand2.complement)
109
+ end
110
+ end
111
+
112
+ class Or < CompoundPredicate
113
+ def complement
114
+ And.new(operand1.complement, operand2.complement)
115
+ end
116
+ end
117
+
118
+ class Equality < Binary
119
+ def ==(other)
120
+ Equality === other and
121
+ ((operand1 == other.operand1 and operand2 == other.operand2) or
122
+ (operand1 == other.operand2 and operand2 == other.operand1))
123
+ end
124
+
125
+ def complement
126
+ Inequality.new(operand1, operand2)
127
+ end
128
+ end
129
+
130
+ class Inequality < Binary
131
+ def ==(other)
132
+ Equality === other and
133
+ ((operand1 == other.operand1 and operand2 == other.operand2) or
134
+ (operand1 == other.operand2 and operand2 == other.operand1))
135
+ end
136
+
137
+ def complement
138
+ Equality.new(operand1, operand2)
139
+ end
140
+ end
141
+
142
+ class GreaterThanOrEqualTo < Binary
143
+ def complement
144
+ LessThan.new(operand1, operand2)
145
+ end
146
+ end
147
+
148
+ class GreaterThan < Binary
149
+ def complement
150
+ LessThanOrEqualTo.new(operand1, operand2)
151
+ end
152
+ end
153
+
154
+ class LessThanOrEqualTo < Binary
155
+ def complement
156
+ GreaterThan.new(operand1, operand2)
157
+ end
158
+ end
159
+
160
+ class LessThan < Binary
161
+ def complement
162
+ GreaterThanOrEqualTo.new(operand1, operand2)
163
+ end
164
+ end
165
+
166
+ class Match < Binary
167
+ def complement
168
+ NotMatch.new(operand1, operand2)
169
+ end
170
+ end
171
+
172
+ class NotMatch < Binary
173
+ def complement
174
+ Match.new(operand1, operand2)
175
+ end
176
+ end
177
+
178
+ class In < Binary
179
+ def complement
180
+ NotIn.new(operand1, operand2)
181
+ end
182
+ end
183
+
184
+ class NotIn < Binary
185
+ def complement
186
+ In.new(operand1, operand2)
187
+ end
188
+ end
189
+ end
190
+ end