Re: Fetch Specifications and boolean values
Re: Fetch Specifications and boolean values
- Subject: Re: Fetch Specifications and boolean values
- From: Chuck Hill <email@hidden>
- Date: Fri, 21 Apr 2006 17:50:34 -0700
On Apr 21, 2006, at 5:30 PM, Daniel DeCovnick wrote:
Hi Chuck,
What you said was about what I'd figured, but here's the result
from the SQL tab when I do (queuespots.hasShipped) = true
Error - could not generate valid SQL.
Exception reason: sqlStringForKeyComparisonQualifier:: attempt to
generate SQL for EOKeyComparisonQualifier 0x1356ba80
'(queuespots.hasShipped = true)' failed because attribute
identified by key 'true' was not reachable from from entity 'Customer'
That might just be the result of EOModeler mis-construing things. It
may still work in code. You could also use Boolean.TRUE in code
which is even more likely to avoid confusion.
What would some typical direct values for the database be?
That entirely depends on how you have modeled booleans. Y, 1, true
are all possibilities.
I'm currently using OpenBase, but that may end up switching to MySQL.
Shudder. I could not recommend that in good conscience. While
OpenBase is not my personal favorite, MySQL.... I'd consider
PostgreSQL if you want free. There is another good option coming
soon, but that I all I can say. You will have to wait.
Also, if I do need to put it into code, it belongs in the Customer
class, correct? Thanks.
Yes. I'd do something like this:
public static NSArray customersWithShippedOrders(EOEditingContext ec) {
return EOUtilities.objectsWithQualifierFormat(ec, "Customer",
"queuespots.hasShipped = $@", new NSArray(Boolean.TRUE));
}
See - it's not so bad in code! :-)
Call it like:
NSArray customers = Customer.customersWithShippedOrders(session
().defaultEditingContext());
Chuck
-Dan
On Apr 21, 2006, at 7:51 PM, Chuck Hill wrote:
Hi Dan,
On Apr 21, 2006, at 4:28 PM, Daniel DeCovnick wrote:
I'm trying to create a fetch specification in EOModeler, where it
returns all the objects where a particular boolean value therein
is true. I've got a "Customer" entity, with a to-many to a
"QueueSpot" entity. I want to create a fetch specification
"shipping history" on Customer where the qualifier is something
like queuespots.hasShipped == true. Am I going about this the
right way in the first place, and if so, how do I get it to work?
Thanks.
At least once upon a time :-) this did _not_ work. Guido says it
worked for him so maybe it is fixed now. It might also work in
the app but not in EOModeler. You will have to experiment. If it
works, the correct qualifier would be
queuespots.hasShipped = true
Note the single equals. EOF should convert true into the correct
value for the database. If it does not, try specifying the value
directly.
If that does not work out, you will need to use an extension to
the qualifiers that come with EOF. I don't know how (or if) you
can add these to EOModeler. I've only used them in code. A
collection of good ones can be found here: http://homepage.mac.com/
i_love_my/code.html
Chuck
--
Coming in late 2006 - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve
specific problems. http://www.global-village.net/products/
practical_webobjects
--
Coming in late 2006 - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden