From ec083687a96af1f35f9fb9e75611cc4bf4f5bf81 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Wed, 26 Nov 2014 15:00:05 -0700 Subject: 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. --- test/visitors/test_mssql.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/visitors') 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) -- cgit v1.2.3