On Apr 21, 2006, at 8:50 PM, Chuck Hill wrote:
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 THINK 1 is working. It's generating what looks like valid SQL at least:
SELECT customerID FROM CUSTOMER WHERE hasShipped = ? AND customerID = customerID ORDER BY creationTime asc
Thanks!
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));
}
Hmm... I think I may be misinterpreting the nature of fetch requests then. Given a particular customer, I want to get an array of all their queuespots which have shipped. Something I could call like:
NSArray history = customer.shippingHistory();
or
NSArray history = shippingHistory(session().defaultEditingContext());
whichever's appropriate.
-Dan
See - it's not so bad in code! :-)
Call it like:
NSArray customers = Customer.customersWithShippedOrders(session().defaultEditingContext());