On Nov 20, 1:07 am, "Dan Kubb (dkubb)" <[EMAIL PROTECTED]> wrote:
> Hi Mark,
>
> > I guess least surprise is in the eye of the beholder. My $0.02 is that
>
> > ...
>
> > post.tags << some_tag
>
> > (if in fact you are going to allow that) imo there is no way to
> > interpret this as meaning something other than an intention to create
> > a join model instance.
>
> The behavior that DM associations are going to have (and may not now)
> is that association << resource will change the state of the objects
> in-memory, creating join instances when possible (more on that
> later).  It won't necessarily persist those changes until you
> explicitly call save.  This is consistent with other parts of DM, such
> as assigning a value to an attribute (resource.attribute = value) --
> this won't cause a change in the data store until you save the
> resource.
>
> I think that's what Dirkjan was referring to when he mentioned POLS.
>
> > Making me explicitly create the join instance
> > and associate it separately in each direction seems like unnecessary
> > repetition to me.
>
> This is not going to be the case permanently.  We are actively working
> on resolving this.  The only reason it probably wasn't added is
> because it's a bit difficult to do properly in all cases, especially
> when multiple :through associations are chained together.
>
> There are even cases where it's impossible to automatically create a
> valid join instance, like say you have a required property without a
> default.  In those cases you'd need to create the join instance
> explicitly.  (although there are work-arounds to this, IMHO they are
> even less elegant)
>
> > Without providing this behavior, I don't really see why datamapper
> > would bother offering the :through option. Am I missing something?
>
> The main reason for using :through right now is that reads seem to
> work ok.  It's writes that kind of suck, although in general I would
> avoid :through associations unless you don't mind the pain.  This will
> not be the case in the near future though.
>
> Dan
> (dkubb)

Thanks Dan. That clarifies and all seems quite reasonable. I'm happy
with having to save the association if the join object is created
automatically. I'm assuming this would be done by calling save on the
receiving object, i.e.

post.tags << some_tag
post.save

I'll be eagerly looking forward to these changes emerging in due
course.

Mark.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to