diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-08-03 17:03:55 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-08-03 17:03:55 -0700 |
commit | ac4fe778577c8b1eea641ef04b4d2b81fc54694d (patch) | |
tree | aac97ab7016466ea5023de44dc8ecb4734d68618 /lib/arel | |
parent | c9517c1b62e7d8acd5a45f72b148942ff2f549a7 (diff) | |
parent | 3712071148485a8a6f2e28944f1d4932ce72b4bd (diff) | |
download | rails-ac4fe778577c8b1eea641ef04b4d2b81fc54694d.tar.gz rails-ac4fe778577c8b1eea641ef04b4d2b81fc54694d.tar.bz2 rails-ac4fe778577c8b1eea641ef04b4d2b81fc54694d.zip |
Merge pull request #56 from dcadenas/master
Add nodes that represent boolean constants
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/factory_methods.rb | 8 | ||||
-rw-r--r-- | lib/arel/nodes.rb | 2 | ||||
-rw-r--r-- | lib/arel/nodes/false.rb | 6 | ||||
-rw-r--r-- | lib/arel/nodes/true.rb | 6 | ||||
-rw-r--r-- | lib/arel/predications.rb | 1 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 8 |
6 files changed, 30 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..611e19633b --- /dev/null +++ b/lib/arel/nodes/false.rb @@ -0,0 +1,6 @@ +module Arel + module Nodes + class False < Arel::Nodes::Node + end + end +end diff --git a/lib/arel/nodes/true.rb b/lib/arel/nodes/true.rb new file mode 100644 index 0000000000..63dd5562e1 --- /dev/null +++ b/lib/arel/nodes/true.rb @@ -0,0 +1,6 @@ +module Arel + module Nodes + class True < Arel::Nodes::Node + 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 |