From 1ab2f4bca30083fbaad7f4a6fe745f580cc06cae Mon Sep 17 00:00:00 2001 From: Jonathan Nevelson Date: Mon, 4 Jun 2012 17:32:43 -0700 Subject: [PATCH 1/2] Fix case where :limit is nil --- lib/active_record/connection_adapters/mysql2_adapter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_record/connection_adapters/mysql2_adapter.rb b/lib/active_record/connection_adapters/mysql2_adapter.rb index 87f6ccf60..1a4c87653 100644 --- a/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -314,13 +314,13 @@ def release_savepoint end def add_limit_offset!(sql, options) - limit, offset = options[:limit], options[:offset] + limit, offset = options.fetch(:limit, 99999999999), options[:offset] if limit && offset sql << " LIMIT #{offset.to_i}, #{sanitize_limit(limit)}" elsif limit sql << " LIMIT #{sanitize_limit(limit)}" elsif offset - sql << " OFFSET #{offset.to_i}" + sql << " LIMIT #{sanitize_limit(limit)} OFFSET #{offset.to_i}" end sql end From 653eea5d1aa6152962c4b88e562a8111a51ba767 Mon Sep 17 00:00:00 2001 From: Jonathan Nevelson Date: Wed, 8 Aug 2012 13:53:24 -0700 Subject: [PATCH 2/2] Change limit value to Arel default --- lib/active_record/connection_adapters/mysql2_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_record/connection_adapters/mysql2_adapter.rb b/lib/active_record/connection_adapters/mysql2_adapter.rb index 1a4c87653..c61ff6de5 100644 --- a/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -314,7 +314,7 @@ def release_savepoint end def add_limit_offset!(sql, options) - limit, offset = options.fetch(:limit, 99999999999), options[:offset] + limit, offset = options.fetch(:limit, 18446744073709551615), options[:offset] if limit && offset sql << " LIMIT #{offset.to_i}, #{sanitize_limit(limit)}" elsif limit