Closed (fixed)
Project:
Migrate
Version:
7.x-2.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Jun 2011 at 19:46 UTC
Updated:
28 Jun 2011 at 16:11 UTC
Two problems prevented me from performing updates to existing records in a table:
1. dbtng does not automatically set 'all_fields' unless $select->fields() is executed on the select object.
2. Keys are never populated, so db_write_record() always does an INSERT
$select = db_select($this->tableName);
// Below is needed; otherwise 'SELECT FROM' is sent, which results in an SQL error
$select->fields($this->tableName, array());
foreach ($this->schema['primary key'] as $key) {
$select->condition($key, $entity->{$key});
// Below is needed; otherwise $primary_key is left empty, leading db_write_record to perform
// an insert.
$primary_key[] = $key;
}
So, either I'm missing something, or this is a bug. I'm happy to roll a patch if this seems right.
Comments
Comment #1
mikeryanIt was close - --update failed regardless of systemOfRecord, so I moved the setting of $primary_key up to the migrate_map_destid1 case and that does the trick.
Thanks!
Comment #2
cmjns commentedIs there a patch for that? Did you roll it into dev?
Comment #3
mikeryanI committed it to git, so it is automatically incorporated into -dev.