From 30c7f0e4b365c85b7a910a0553ed936be56b9c4b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 25 Apr 2011 12:01:22 -0700 Subject: add a factory method for production LOWER functions --- lib/arel/factory_methods.rb | 6 ++++++ test/test_factory_methods.rb | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/lib/arel/factory_methods.rb b/lib/arel/factory_methods.rb index 2ced1f8971..9fd0878ada 100644 --- a/lib/arel/factory_methods.rb +++ b/lib/arel/factory_methods.rb @@ -25,5 +25,11 @@ module Arel def grouping expr Nodes::Grouping.new expr end + + ### + # Create a LOWER() function + def lower column + Nodes::NamedFunction.new 'LOWER', [column] + end end end diff --git a/test/test_factory_methods.rb b/test/test_factory_methods.rb index 6506d3c472..50f77c3175 100644 --- a/test/test_factory_methods.rb +++ b/test/test_factory_methods.rb @@ -22,6 +22,13 @@ module Arel assert_instance_of Nodes::On, on assert_equal :one, on.expr end + + def test_lower + lower = @factory.lower :one + assert_instance_of Nodes::NamedFunction, lower + assert_equal 'LOWER', lower.name + assert_equal [:one], lower.expressions + end end end end -- cgit v1.2.3