diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-16 15:02:37 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-16 15:02:37 -0700 |
commit | f47d083c5bbbac1a807954a20a35888024fb4707 (patch) | |
tree | d175a0ed86ec7589a64047902b710f76f4884bc5 | |
parent | 6544a9b36976f8168b98d3a56a3acd952f1a4d18 (diff) | |
download | rails-f47d083c5bbbac1a807954a20a35888024fb4707.tar.gz rails-f47d083c5bbbac1a807954a20a35888024fb4707.tar.bz2 rails-f47d083c5bbbac1a807954a20a35888024fb4707.zip |
table responds to take
-rw-r--r-- | lib/arel/table.rb | 4 | ||||
-rw-r--r-- | spec/arel/table_spec.rb | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb index b629e0755b..2df20e50e8 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -26,6 +26,10 @@ module Arel tm.project thing end + def take amount + tm.take amount + end + def columns @columns ||= @engine.connection.columns(@name, "#{@name} Columns").map do |column| Attributes.for(column).new self, column.name, column diff --git a/spec/arel/table_spec.rb b/spec/arel/table_spec.rb index dbb21d6d69..bc3d6938a7 100644 --- a/spec/arel/table_spec.rb +++ b/spec/arel/table_spec.rb @@ -18,6 +18,14 @@ module Arel end end + describe 'take' do + it "should add a limit" do + manager = @relation.take 1 + manager.project '*' + manager.to_sql.should be_like %{ SELECT * FROM "users" LIMIT 1 } + end + end + describe 'project' do it 'can project' do manager = @relation.project '*' |