diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-11-26 15:00:05 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-11-26 15:00:05 -0700 |
commit | ec083687a96af1f35f9fb9e75611cc4bf4f5bf81 (patch) | |
tree | 627cd232a28f06e795a5ab7d732b02b878803104 /test/visitors | |
parent | b40dfdde690ea32d658393e9e81c6ad36d23891f (diff) | |
download | rails-ec083687a96af1f35f9fb9e75611cc4bf4f5bf81.tar.gz rails-ec083687a96af1f35f9fb9e75611cc4bf4f5bf81.tar.bz2 rails-ec083687a96af1f35f9fb9e75611cc4bf4f5bf81.zip |
Remove deprecated method "Table#primary_key"
The only place this method was still used is on the MSSQL visitor. The
visitor has all of the objects required to inline this lookup there.
Since the `primary_key` method on the connection adapter will perform a
query when called, we can cache the result on the visitor.
Diffstat (limited to 'test/visitors')
-rw-r--r-- | test/visitors/test_mssql.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/visitors/test_mssql.rb b/test/visitors/test_mssql.rb index a3efcb8b27..7574aeb0a2 100644 --- a/test/visitors/test_mssql.rb +++ b/test/visitors/test_mssql.rb @@ -26,6 +26,25 @@ module Arel sql.must_be_like "SELECT _t.* FROM (SELECT ROW_NUMBER() OVER (ORDER BY \"users\".\"id\") as _row_num FROM \"users\") as _t WHERE _row_num BETWEEN 1 AND 10" end + it 'caches the PK lookup for order' do + connection = MiniTest::Mock.new + connection.expect(:primary_key, ["id"], ["users"]) + + # We don't care how many times these methods are called + def connection.quote_table_name(*); ""; end + def connection.quote_column_name(*); ""; end + + @visitor = MSSQL.new(connection) + stmt = Nodes::SelectStatement.new + stmt.cores.first.from = @table + stmt.limit = Nodes::Limit.new(10) + + compile(stmt) + compile(stmt) + + connection.verify + end + it 'should go over query ORDER BY if .order()' do stmt = Nodes::SelectStatement.new stmt.limit = Nodes::Limit.new(10) |