On Feb 1, 2008 4:49 PM, Sam Tregar <[EMAIL PROTECTED]> wrote:
> But without the reload subscribed_lists() keeps returning the old list.  Is
> there a way to tip off Rose that any cached lists for a particular
> relationship are stale?  Or something I'm doing wrong?

All get_set* relationship accessors will will only fetch the related
object(s) from the db once, after which they will just return what
they've previously fetched.  (The docs need to be more clear about
this, I think.)  This is considered a feature :)

To make an object forget a previously fetched set, just set it to undef:

    @lists = $user->subscribed_lists(); # get list
    ...                                 # modify list in the db
    $user->subscribed_lists(undef);     # forget old list
    @lists = $user->subscribed_lists(); # get new list

Note that this is very different from passing an empty list ([]),
which says "replace the existing set of rows in the database with this
new (empty, in this case) list."  That's not what you want :)

(As an aside, unlike the get_set* relationship methods types, the
"find" method type fetches from the db every time.)

-John

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to