Because this will first delete all rows related to the object then
re-populate the table the primary key column grows very, very quickly.
Some scripts I'm converting over to Rose run every couple hours and work
with thousands of objects each time. What I needed was for this process
to first update or add new objects then delete any objects that did not
exist in the array.
The following is what I've done for now, but it involves editing the
Rose::DB::Object::MakeMethods::Generic directly. I was trying to get
around from using the map class directly because I like the ease of
$object->manytomanys($array_ref_of_objects).
I guess my questions are, do others have this issue? and what is the
best way to implement this?
line 5243:
# Delete any existing objects
#K my $deleted =
#K $map_manager->$map_delete_method(object_class => $map_class,
#K where => [
%join_map_to_self ],
#K db => $db);
#K
my $delete_exceptions = [];
#K die $map_manager->error unless(defined $deleted);
line 5347:
my %exception_key_map;
foreach my $fkey_column
($map_record->meta->primary_key_columns) {
$exception_key_map{'!'.$fkey_column} =
$map_record->$fkey_column;
}
push @$delete_exceptions, %exception_key_map;
}
my @delete_where = (%join_map_to_self,@$delete_exceptions);
my $delete = $map_manager->$map_delete_method(object_class =>
$map_class,
where => \@delete_where,
db => $db);
If you've done the math and you really think you're going to overflow
a 32-bit value, then you might want to change that primary key to a
64-bit value.
> Some scripts I'm converting over to Rose run every couple hours and work
> with thousands of objects each time. What I needed was for this process
> to first update or add new objects then delete any objects that did not
> exist in the array.
The reason the standard code doesn't work the way your modified code
does is that there may be many, many rows to delete. Building a
single query that deletes from some table with a "where" clause of
potentially unlimited size runs the very real risk of blowing past the
maximum query and/or clause size of the database.
-John
On Thu, Aug 7, 2008 at 12:21 AM, Kevin McGrath <kmcg...@baknet.com> wrote:Because this will first delete all rows related to the object then re-populate the table the primary key column grows very, very quickly.If you've done the math and you really think you're going to overflow a 32-bit value, then you might want to change that primary key to a 64-bit value.
Some scripts I'm converting over to Rose run every couple hours and work with thousands of objects each time. What I needed was for this process to first update or add new objects then delete any objects that did not exist in the array.The reason the standard code doesn't work the way your modified code does is that there may be many, many rows to delete. Building a single query that deletes from some table with a "where" clause of potentially unlimited size runs the very real risk of blowing past the maximum query and/or clause size of the database. -John