diff options
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 14 | ||||
-rw-r--r-- | activerecord/lib/active_record/locking.rb | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 82ebf6bb4a..edfdc44f83 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -174,11 +174,11 @@ module ActiveRecord end def add_limit_offset!(sql, options) - unless options[:limit].blank? - unless options[:offset].blank? - sql << " LIMIT #{options[:offset]}, #{options[:limit]}" - else + if options[:limit] + if options[:offset].blank? sql << " LIMIT #{options[:limit]}" + else + sql << " LIMIT #{options[:offset]}, #{options[:limit]}" end end end @@ -206,9 +206,9 @@ module ActiveRecord @connection.query_with_result = true result = execute(sql, name) rows = [] - #all_fields_initialized = result.fetch_fields.inject({}) { |all_fields, f| all_fields[f.name] = nil; all_fields } - #result.each_hash { |row| rows << all_fields_initialized.dup.update(row) } - result.each_hash { |row| rows << row } + all_fields_initialized = result.fetch_fields.inject({}) { |all_fields, f| all_fields[f.name] = nil; all_fields } + result.each_hash { |row| rows << all_fields_initialized.merge(row) } + #result.each_hash { |row| rows << row } result.free rows end diff --git a/activerecord/lib/active_record/locking.rb b/activerecord/lib/active_record/locking.rb index c8868bed3c..71a4666e17 100644 --- a/activerecord/lib/active_record/locking.rb +++ b/activerecord/lib/active_record/locking.rb @@ -34,7 +34,7 @@ module ActiveRecord affected_rows = connection.update(<<-end_sql, "#{self.class.name} Update with optimistic locking") UPDATE #{self.class.table_name} - SET #{quoted_comma_pair_list(attributes_with_quotes(false))} + SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} WHERE #{self.class.primary_key} = #{quote(id)} AND lock_version = #{quote(previous_value)} end_sql |