-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Please find enclosed a patch that implement/use the PosgreSQL "LIMIT"
keyword in PostgreSQLAdaptor.
Best regards.
Thierry (aka BeFree).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkm9csEACgkQe80ldkiJNIawJwCgqKDCRNIDBFTfeWIwWGBDxkUX
W58AoKXmQ0jKuMSLTZIH5gaHr2oydC1E
=NCFg
-----END PGP SIGNATURE-----
Index: EOAdaptors/PostgreSQLAdaptor/PostgreSQLExpression.m
===================================================================
--- EOAdaptors/PostgreSQLAdaptor/PostgreSQLExpression.m (révision 28078)
+++ EOAdaptors/PostgreSQLAdaptor/PostgreSQLExpression.m (copie de travail)
@@ -375,7 +375,50 @@
{
return @"FOR UPDATE";
}
+// *******************************************************************************************
+// Begin [email protected] (aka BeFree) additions
+// **
+//
+// mimic the lockClause method but for the LIMIT keyword
+//
+// **
+- (NSString *)limitClause
+{
+ return @"LIMIT";
+}
+// **
+//
+// overload the based implementation (EOSQLExpression) to handle fetchLimit with the postgreSQL "LIMIT" clause.
+//
+// **
+- (void)prepareSelectExpressionWithAttributes: (NSArray *)attributes
+ lock: (BOOL)flag
+ fetchSpecification: (EOFetchSpecification *)fetchSpecification
+{
+ unsigned limit = 0;
+
+ // first call super since the LIMIT keyword by convention is allways add at the end of the statement. So we can let
+ // the default implementation do the job and add to the end of the statement the "limit" keyword if required
+
+ [super prepareSelectExpressionWithAttributes:attributes lock:flag fetchSpecification:fetchSpecification];
+
+ if( fetchSpecification )
+ {
+ limit = [fetchSpecification fetchLimit];
+ if (limit != 0 )
+ {
+ // this means LIMIT
+ // so get the statement
+ NSString* newStatement = [NSString stringWithFormat:@"%@ %@ %u",[self statement],[self limitClause],limit];
+ [self setStatement:newStatement];
+ }
+ }
+}
+
+
+// end [email protected] additions
+// *******************************************************************************************
- (NSString *)assembleSelectStatementWithAttributes: (NSArray *)attributes
lock: (BOOL)lock
qualifier: (EOQualifier *)qualifier
_______________________________________________
Gnustep-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnustep-dev