app/models/collection_job.rb
# TODO - this will lock the table. (INSERT SELECT always does.) We want to change this to select first and
# then handle the insert either in blocks or using a file or some-such.
this will lock the table. (INSERT SELECT always does.) We want to change this to select first and
then handle the insert either in blocks or using a file or some-such.
this will lock the table . ( INSERT SELECT always does . ) We want to change this to select first and then handle the insert either in blocks or using a file or some - such .
def copy
    transaction do
      delete_duplicates if overwrite? 
      columns = user_owns_source? ? unhandled_columns : SAFE_COLUMNS
      affected = watch_inserts do
        collections.each do |target_collection|
          CollectionItem.connection.update(EOL::Db.sanitize_array([%(
            INSERT IGNORE INTO collection_items (collection_id, #{columns})
              SELECT ?, #{columns}
              FROM collection_items
              WHERE #{source_where_clause}
          ),
          target_collection.id,
          source_where_argument]))
        end
      end
      copy_references if user_owns_source?
      affected
    end
  end
def copy transaction do delete_duplicates if overwrite? columns = user_owns_source? ? unhandled_columns : SAFE_COLUMNS affected = watch_inserts do collections . each do | target_collection | CollectionItem . connection . update ( EOL :: Db . sanitize_array ( [ %(
            INSERT IGNORE INTO collection_items (collection_id, #{columns})
              SELECT ?, #{columns}
              FROM collection_items
              WHERE #{source_where_clause}
          ) , target_collection . id , source_where_argument ] ) ) end end copy_references if user_owns_source? affected end end
TODO - this will lock the table.
TODO - this will lock the table .
# Since we're overwriting, we need to get rid of conflicts # Users only get all the ancillary data (annotation and sorts and the like) if they own the source: