From e3a2fae05dfce39bbac86780c28b102acc3aa68f Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 25 Mar 2010 12:27:34 -0300 Subject: Add add_limit_offset! to adapters. --- .../lib/active_record/connection_adapters/mysql_adapter.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 1f1df7e8c3..6946701ee5 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -375,6 +375,18 @@ module ActiveRecord execute("RELEASE SAVEPOINT #{current_savepoint_name}") end + def add_limit_offset!(sql, options) #:nodoc: + limit, offset = options[:limit], 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}" + end + sql + end + # SCHEMA STATEMENTS ======================================== def structure_dump #:nodoc: -- cgit v1.2.3 From 5176b28852dc6d0654cdf601d590bddbd6e6da1e Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Fri, 26 Mar 2010 13:09:38 +0430 Subject: Better MySQL Error message. [#3775 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 6946701ee5..521bd810d0 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -61,7 +61,7 @@ module ActiveRecord begin require_library_or_gem('mysql') rescue LoadError - $stderr.puts '!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.' + $stderr.puts '!!! Please install the mysql gem and try again: gem install mysql.' raise end end -- cgit v1.2.3