[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch for gdl2 to handle LIMIT PostgreSQL keyword in PostgreSQLAdaptor.
From: |
Thierry DELHAISE |
Subject: |
Patch for gdl2 to handle LIMIT PostgreSQL keyword in PostgreSQLAdaptor. |
Date: |
Sun, 15 Mar 2009 22:27:46 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20090105) |
-----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 address@hidden (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 address@hidden additions
+//
*******************************************************************************************
- (NSString *)assembleSelectStatementWithAttributes: (NSArray *)attributes
lock: (BOOL)lock
qualifier: (EOQualifier *)qualifier
- Patch for gdl2 to handle LIMIT PostgreSQL keyword in PostgreSQLAdaptor.,
Thierry DELHAISE <=