I have a similar problem trying to use a flattened relationship in my
WOUnitTesting.

I have this:

Study <->> StudyPeriod <->> StudySchedule

My flattened relationship periodSchedules is defined in my EOModel for
Entity Study as studyPeriods.studySchedules named "studySchedules".

I don't think it makes sense to flatten across more than one to-many relationship. Asking a study for it's studySchedules would give you an array of arrays of studySchedules (I think).


I create the study, its periods and the periods' schedules using
WOUTMockEditingContext and the createSavedObject and
addRelationshipToBothSides... methods.  All works fine when I
enumerated over the realtionships.  It passes all of my tests for
custom methods I have.  However, whenever accessing my flattened
relationship ("studySchedules"), rather than enumerating over the
to-many relationships, the result is always an empty array.

I am not sure if this is related to the faulting of flattenen
relationships or something specific with using the
WOUTMockEditingContext (not the newest version WOUT2)

You'll get the same result when using an EOEditingContext, so I don't think your problem is related to using the MockEC. Sorry, I don't know what the solution is. I've read in some of Apple's old docs that: "flattening is a technique you should only use under certain conditions. Instead of flattening an attribute or a relationship, you can instead directly traverse the object graph, either programmatically or by using key paths. This ensures that your application has an internally consistent view of the data." I only use flattening on many-to-many relationships to bypass the join- entity, which works fine.


Christian

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to