On Mar 2, 2009, at 4:26 PM, Kieran Kelleher wrote:

Hi Chuck,

I was half-expecting this outcome, especially after examining how the different SQLHelpers implement limitSqlExpression method. I am tempted to implement an ERXSpec subclass though to auto limit for databases with supported ERXSqlHelpers ...... it just seems like the right default behaviour to have....

I don't have any arguments against it. I am not sure if fetch spec is the place for this, probably lower in EOAccess.

Chuck


Thanks, Kieran

On Mar 2, 2009, at 6:43 PM, Chuck Hill wrote:


On Mar 2, 2009, at 1:42 PM, Kieran Kelleher wrote:

I always thought that EOFetchSpecification.setFetchLimit( int n) would generate SQL with LIMIT n tacked onto the end of the SQL statement, but it appears not to.

This is the default behavior as not all databases implement this. Specific plugins add this, IIRC.

Chuck


Instead it fetches the all qualifying records and does the LIMIT in memory?! Has this always been the case .... or is it just the MySQL driver?

For example:

<snip>
// Fetch the most recent shipped message
ERXSortOrderings s = CTMessage.XKEY_OID.descs();

ERXFetchSpecification<CTMessage> fs = new ERXFetchSpecification<CTMessage>(CTMessage.ENTITY_NAME,null,s);

fs.setFetchLimit(1);

System .out.println("MailingAddressUtilitiesTests.suppressionTest(): fs.SQL = " + ERXEOAccessUtilities.sqlForFetchSpecification(ec, fs));

NSArray<CTMessage> objects = fs.fetchObjects(ec);
</snip>


..... generates the following SQL without "LIMIT 1" !!!

SELECT t0.oid, t0.oidcampaign, t0.oiddatarecord, t0.oidjob, t0.oidlocation, t0.oidmediatemplate, t0.recaddtime, t0.recadduser, t0.recmodtime, t0.recmoduser, RTRIM(t0.workflowstate) FROM message t0 ORDER BY t0.oid DESC;
_______________________________________________
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/chill%40global-village.net

This email sent to [email protected]


--
Chuck Hill             Senior Consultant / VP Development

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









--
Chuck Hill             Senior Consultant / VP Development

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