Browse files

r1607@asus: jeremy | 2005-07-02 23:36:52 -0700

 Rollback MysqlAdapter#select speedup; fix add_limit_offset


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1625 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 018e12d commit b02776c2321004e1b3855140eb0a6590a634de2d @jeremy jeremy committed Jul 3, 2005
View
14 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -174,11 +174,11 @@ def structure_dump
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 @@ def select(sql, name = nil)
@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
View
2 activerecord/lib/active_record/locking.rb
@@ -34,7 +34,7 @@ def update_with_lock #:nodoc:
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

0 comments on commit b02776c

Please sign in to comment.