diff options
author | Alexander Staubo <alex@origo.no> | 2012-02-23 14:06:05 +0100 |
---|---|---|
committer | Alexander Staubo <alex@origo.no> | 2012-02-23 14:06:05 +0100 |
commit | 2db4ec6a28a59a3f74a4979ae5bc117e5c7573c4 (patch) | |
tree | 8670d0a9f828d53faab7692ae7945836732e4ba4 /test | |
parent | a1a6fbc189d0cb8c44606eafcb8bda7a010554c0 (diff) | |
download | rails-2db4ec6a28a59a3f74a4979ae5bc117e5c7573c4.tar.gz rails-2db4ec6a28a59a3f74a4979ae5bc117e5c7573c4.tar.bz2 rails-2db4ec6a28a59a3f74a4979ae5bc117e5c7573c4.zip |
Add #extract, which produces ANSI SQL function EXTRACT(<field> from <expr>).
Diffstat (limited to 'test')
-rw-r--r-- | test/nodes/test_extract.rb | 19 |
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 |