aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel')
-rw-r--r--lib/arel/factory_methods.rb8
-rw-r--r--lib/arel/nodes.rb2
-rw-r--r--lib/arel/nodes/false.rb17
-rw-r--r--lib/arel/nodes/true.rb17
-rw-r--r--lib/arel/predications.rb1
-rw-r--r--lib/arel/visitors/to_sql.rb8
6 files changed, 52 insertions, 1 deletions
diff --git a/lib/arel/factory_methods.rb b/lib/arel/factory_methods.rb
index 9fd0878ada..3b16feae10 100644
--- a/lib/arel/factory_methods.rb
+++ b/lib/arel/factory_methods.rb
@@ -2,6 +2,14 @@ module Arel
###
# Methods for creating various nodes
module FactoryMethods
+ def create_true
+ Arel::Nodes::True.new
+ end
+
+ def create_false
+ Arel::Nodes::False.new
+ end
+
def create_table_alias relation, name
Nodes::TableAlias.new(relation, name)
end
diff --git a/lib/arel/nodes.rb b/lib/arel/nodes.rb
index 9edf3a9a95..e37b09a8ac 100644
--- a/lib/arel/nodes.rb
+++ b/lib/arel/nodes.rb
@@ -8,6 +8,8 @@ require 'arel/nodes/update_statement'
# terminal
require 'arel/nodes/terminal'
+require 'arel/nodes/true'
+require 'arel/nodes/false'
# unary
require 'arel/nodes/unary'
diff --git a/lib/arel/nodes/false.rb b/lib/arel/nodes/false.rb
new file mode 100644
index 0000000000..4196070946
--- /dev/null
+++ b/lib/arel/nodes/false.rb
@@ -0,0 +1,17 @@
+module Arel
+ module Nodes
+ class False < Arel::Nodes::Node
+ def not
+ True.new
+ end
+
+ def or right
+ right
+ end
+
+ def and right
+ self
+ end
+ end
+ end
+end
diff --git a/lib/arel/nodes/true.rb b/lib/arel/nodes/true.rb
new file mode 100644
index 0000000000..82f20837f8
--- /dev/null
+++ b/lib/arel/nodes/true.rb
@@ -0,0 +1,17 @@
+module Arel
+ module Nodes
+ class True < Arel::Nodes::Node
+ def not
+ False.new
+ end
+
+ def or right
+ self
+ end
+
+ def and right
+ right
+ end
+ end
+ end
+end
diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb
index 4b124ce05c..e3f72d46a2 100644
--- a/lib/arel/predications.rb
+++ b/lib/arel/predications.rb
@@ -1,6 +1,5 @@
module Arel
module Predications
-
def not_eq other
Nodes::NotEqual.new self, other
end
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index 933edc15f2..8aec4cb147 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -90,6 +90,14 @@ key on UpdateManager using UpdateManager#key=
o.alias ? " AS #{visit o.alias}" : ''}"
end
+ def visit_Arel_Nodes_True o
+ "TRUE"
+ end
+
+ def visit_Arel_Nodes_False o
+ "FALSE"
+ end
+
def table_exists? name
@pool.table_exists? name
end