To edit pages or tickets please login with username/password: aaf/aaf

Ticket #163 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

records_for_rebuild mysql specific batch find :all assumes integer primary key

Reported by: aaf Assigned to: jk
Priority: major Milestone: 0.4.2
Component: 0plugin Version:
Keywords: primary key non-integer Cc:

Description

In records_for_rebuild in class_method.rb offset is assigned and manipulated from :id. The code assumes that :id is a sequential integer value. If the primary_key is a UUID this mechanism fails. And subsequently, when records_for_rebuild yields offset to index_model, index_model attempts to convert offset to a float and results in an exception. In a lot of cases with UUIDs this result will be a Float out of range exception.

Change History

08/16/07 21:15:05 changed by aaf

I recommend that the following changes be made to records_for_rebuild. This selects a batch. I've tested with some large tables (>70K records) and have no problem indexing now.

offset = 1 while (rows = find :all, :limit => "#{offset},#{batch_size}").any?

offset += batch_size yield rows, offset

end

08/16/07 21:17:52 changed by aaf

oops lost my code block

          offset = 1
          while (rows = find :all, :limit => "#{offset},#{batch_size}").any?
            offset += batch_size
            yield rows, offset
          end

08/26/07 19:37:49 changed by jk

  • status changed from new to assigned.
  • milestone set to 0.4.2.

08/31/07 21:54:59 changed by jk

  • status changed from assigned to closed.
  • resolution set to fixed.

I added a new option to acts_as_ferret so this feature can be turned off when using MySQL with non-integer PKs in the 'id' column:

acts_as_ferret :fields => {...}, :mysql_fast_batches => false

To edit pages or tickets please login with username/password: aaf/aaf