Skip to content

Commit

Permalink
add a factory method for production LOWER functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Apr 25, 2011
1 parent f72989d commit 30c7f0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/arel/factory_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ def create_on expr
def grouping expr
Nodes::Grouping.new expr
end

###
# Create a LOWER() function
def lower column
Nodes::NamedFunction.new 'LOWER', [column]
end
end
end
7 changes: 7 additions & 0 deletions test/test_factory_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def test_create_on
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

0 comments on commit 30c7f0e

Please sign in to comment.