Hi Xavier,

> Auto validation on primary keys sucks because they often aren't know at
> validation time (such as creating new objects in a tree - the children
> don't know the FK, which is often a part of the PK, until after
> validation and after save of the parent).
>
> I am using the following monkey patch in my current project to default
> auto_validation on PKs to false, but still allow it to be overridden to
> true. How do people feel about making it default behaviour?

I think it might be important to differentiate between primary keys
and properties with generated default values.

A String or UUID primary key should probably still be validated
automatically. Even an Integer primary key should have auto-validation
turned on. What probably shouldn't have auto-validation turned on are
Serial properties, since it's expected that the adapter will set the
value inside #create when it is undefined.

> Another behaviour I've noted is that :auto_validation on a belongs_to
> isn't passed down to the properties, but I think this is a real bug so
> will put together a proper test case/patch for it.

Yes, that sounds like a bug, or possibly something that was deferred
due to time constraints. If I recall, I had to add explicit logic to
allow :key and other options to be passed down to the inferred FK
properties. Ideally I'd like to get to the point where all the
applicable options are passed down to those properties.

--

Dan
(dkubb)

-- 
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