Re: Live_Object interaction with VIEWs
[prev]
[thread]
[next]
[Date index for 2004/08/02]
On Thu, 2004-07-29 at 16:01, Paul Makepeace wrote:
> my ($perms) = Corrobbo::DBI::UsersAndPermissions->search(@args);
> return undef unless defined $perms;
>
> if ($permission) { # a 'set' operation
> # Get the underlying table (this is a VIEW)
> my $perm = $perms->user_perm;
> $perm->permission($permission);
> $perm->update;
> $perm->dbi_commit;
> undef $perms;
> ($perms) = Corrobbo::DBI::UsersAndPermissions->search(@args);
> }
>
> $perms->permission;
>
> So from your advice I put that 'undef' in there which seems to have
> solved it. Frankly, it looks really odd to me. On the other hand without
> a way to inform CDBI that the view is dependent on a table that has been
> CDBI-ified I can't immediately see any other way.
It's not related to using a view. What's happening here is that you are
loading a row into memory, and then querying for that same row. If you
don't do the undef, the row is still there and Class::DBI says "oh, you
already have an active object for this row, here it is."
If undef looks too strange, you can use
$perm->remove_from_object_index() instead.
There are also some patches from Tim Bunce that have been posted to the
list, which might be useful to you.
- Perrin