aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'test/nodes')
-rw-r--r--test/nodes/test_extract.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/nodes/test_extract.rb b/test/nodes/test_extract.rb
new file mode 100644
index 0000000000..bd1dfa4750
--- /dev/null
+++ b/test/nodes/test_extract.rb
@@ -0,0 +1,19 @@
+require 'helper'
+
+describe Arel::Nodes::Extract do
+ it "should extract field" do
+ table = Arel::Table.new :users
+ table[:timestamp].extract('date').to_sql.must_be_like %{
+ EXTRACT(DATE FROM "users"."timestamp")
+ }
+ end
+
+ describe "as" do
+ it 'should alias the extract' do
+ table = Arel::Table.new :users
+ table[:timestamp].extract('date').as('foo').to_sql.must_be_like %{
+ EXTRACT(DATE FROM "users"."timestamp") AS foo
+ }
+ end
+ end
+end