Re: Case sensitivity problem with primary keys in EOEditingContext.faultForRawRow

Marc Gumpinger <[email protected]> Mon, 31 Jul 2006 11:10:31 +0200
Newsgroups gmane.comp.web.webobjects.admin
Message-ID <[email protected]>
Thank you very much for that hint. That probably did the better trick.

Since that question sparked some discussion, I should mention a bit  
more about the original problem.
I was using Project Wonder's  
ERXEOAccessUtilities.rawRowsForSQLExpression to get the raw rows  
(using WO 5.2.3 and postgres).
The resulting dictionary contained the database column names, not the  
eomodel's attribute names. In my case, the primary key's column name  
was "ID" and the eomodel's attribute name was "id". The funny thing  
was, that EOF was able to match all the column names - except for the  
primary key.

To give an example, the original raw row dict was something like:
{ID=123, SOME_COLUMN='Hello', ...}
EOEditingContext.faultForRawRow was not able to turn that into a  
fault because it didn't find the primary key (... "does not contain  
primary key information for entity"...).

However, this dict worked:
{ID=123, id=123, SOME_COLUMN='Hello', ...}

And that's what was kind of strange to me, because a raw row dict  
with mixed column names and attribute names for pks works.


Cheers
Marc




Am 30.07.2006 um 19:27 schrieb Brendan Duddridge:

> rawRowsForSQL allows you to pass in an NSArray of keys that will be  
> used to map the columns from the database to the attributes in your  
> model.
>
> ____________________________________________________________________
> Brendan Duddridge | CTO | 403-277-5591 x24 |  [email protected]
>
> ClickSpace Interactive Inc.
> Suite L100, 239 - 10th Ave. SE
> Calgary, AB  T2G 0V9
>
> http://www.clickspace.com
>
> On Jul 29, 2006, at 12:59 PM, webobjects-admin- 
> [email protected] wrote:
>
>>
>> From: Marc Gumpinger <[email protected]>
>> Date: July 29, 2006 10:19:48 AM MDT (CA)
>> To: [email protected]
>> Cc: [email protected]
>> Subject: Case sensitivity problem with primary keys in  
>> EOEditingContext.faultForRawRow
>>
>>
>> Hi,
>>
>> I have a raw row (an NSDictionary) that I got from fetching for  
>> raw row using an EOSQLExpression.
>> When I ask the editing context to turn that raw row into a fault  
>> using faultForRawRow, the ec tells me that there was no primary  
>> information in the raw row dictionary.
>> (EODatabaseContext throws an IllegalArgumentException with the  
>> message: ... "does not contain primary key information for  
>> entity" ...)
>>
>> After digging through the EOF source I found that the simple root  
>> of the problem is case sensitivity.
>> EOEntity._globalIDForRowIsFinal which is supposed to return the  
>> EOKeyGlobalID iterates through the raw rows dictionary's keys to  
>> find those that match the entity's primaryKeyAttributeNames.
>>
>> Now the problem - at least in my case - is, that the dictionary's  
>> keys are all upper case (here "ID") since that's what the database  
>> returned. However, the primary key's name in the eomodel is all  
>> lower case (here "id"). For this simple reason, the entire  
>> faultForRawRow doesn't work.
>>
>>
>> Is there an official solution to this problem?
>> I mean, it was no effort, to adopt the dictionary correspondingly  
>> so that the keys also match in case sensitivity. However, due to  
>> EOFs maturity I'm sure that I either made a mistake or oversaw  
>> something.
>>
>>
>> Thank you in advance
>> Marc
>
> _______________________________________________
> WebObjects-admin mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-admin


		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de