Commits

Tuukka Norri committed 212aafe

Added some methods to make it easier to fetch modification sets from BXPGInterface
- There are some problems with the tests, though.

  • Participants
  • Parent commits a04da7b
  • Branches PGTS

Comments (0)

Files changed (3)

File Framework/Framework.xcodeproj/project.pbxproj

 		0867D690FE84028FC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 53BA4FD208804E6B00BFAFB5 /* Build configuration list for PBXProject "Framework" */;
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 0867D691FE84028FC02AAC07 /* Framework */;
 			productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;

File Framework/Sources/PGTSModificationNotifier.h

 
 @class PGTSTableInfo;
 @class PGTSConnection;
+@class PGTSResultSet;
 
 
 enum PGTSTableOperation 
 	 notificationName: (NSString *) notificationName;
 - (NSDictionary *) lastModificationForTable: (PGTSTableInfo *) table connection: (PGTSConnection *) connection;
 - (void) checkInModificationTableNamed: (NSString *) modificationTableName;
+- (PGTSResultSet *) checkModificationsInTable: (PGTSTableInfo *) table
+										query: (NSString *) query
+								   parameters: (NSArray *) parameters;
+- (PGTSResultSet *) checkModificationsInTableNamed: (NSString *) name
+											 query: (NSString *) query 
+										parameters: (NSArray *) parameters;
+- (NSString *) modificationTableName: (PGTSTableInfo *) table;
 
 @end

File Framework/Sources/PGTSModificationNotifier.m

 
 - (void) checkForModificationsInTable: (PGTSTableInfo *) table
 {
-    [self checkInModificationTableNamed: [notificationNames objectAtIndex: [table oid]]];
+    [self checkInModificationTableNamed: [self modificationTableName: table]];
 }
 
 - (void) checkInModificationTableNamed: (NSString *) modificationTableName
 	else
         backendPID = [NSNumber numberWithInt: [connection backendPID]];
     
-    NSString* query = [NSString stringWithFormat: 
-        @"SELECT * FROM %@ ($1::timestamp, $2)", modificationTableName];
-    PGTSResultSet* res = [connection executeQuery: query parameters: [self lastCheckForTable: modificationTableName], backendPID];
+    NSString* query = [NSString stringWithFormat: @"SELECT * FROM %@ ($1::timestamp, $2)", modificationTableName];
+	NSArray* parameters = [NSArray arrayWithObjects: [self lastCheckForTable: modificationTableName], backendPID];
+	PGTSResultSet* res = [self checkModificationsInTableNamed: modificationTableName
+														query: query 
+												   parameters: parameters];
     
     NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
     NSMutableDictionary* baseUserInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys:
             
             [rows addObject: row];
             lastType = modificationType;
-            [self setLastCheck: [res valueForKey: @"" PGTS_SCHEMA_NAME "_modification_timestamp"] forTable: modificationTableName];
             [res advanceRow];
         }        
     }
 }
 
+- (PGTSResultSet *) checkModificationsInTable: (PGTSTableInfo *) table
+										query: (NSString *) query
+								   parameters: (NSArray *) parameters
+{
+	return [self checkModificationsInTableNamed: [self modificationTableName: table]
+										  query: query parameters: parameters];
+}
+
+- (PGTSResultSet *) checkModificationsInTableNamed: (NSString *) name
+											 query: (NSString *) query 
+										parameters: (NSArray *) parameters
+{
+    PGTSResultSet* retval = [connection executeQuery: query parameterArray: parameters];
+	while ([retval advanceRow])
+		[self setLastCheck: [retval valueForKey: @"" PGTS_SCHEMA_NAME "_modification_timestamp"] forTable: name];
+	[retval goBeforeFirstRow];
+	return retval;
+}
+
+- (NSString *) modificationTableName: (PGTSTableInfo *) table
+{
+	return [notificationNames objectAtIndex: [table oid]];
+}
+
 - (NSArray *) sentNotifications
 {
     if (nil == sentNotifications)