From a224a100db2f76f7100af0f082219b27f67f675e Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 13 Aug 2012 14:35:00 +0000 Subject: [PATCH] Monotone-Parent: 7bc959b7bdbff70b4793f01076b797130e83fd01 Monotone-Revision: 56f8217cb19f50d50429b4f745548b63bd418877 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-08-13T14:35:00 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++++++++ OpenChange/GCSSpecialQueries+OpenChange.m | 5 +++++ OpenChange/SOGoMAPIDBFolder.m | 9 +++++---- OpenChange/SOGoMAPIDBObject.m | 12 ++++++++---- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 869bdac3d..a3950b176 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2012-08-13 Wolfgang Sourdeau + * OpenChange/SOGoMAPIDBFolder.m + (-childKeysOfType:includeDeleted:matchingQualifier:andSortOrderings:): + records now have a c_parent_path column in order to avoid fetch + the children of children due to the nature of our "LIKE" clause. + + * OpenChange/SOGoMAPIDBObject.m (-save): records now have a + c_parent_path. + * OpenChange/MAPIStoreMailFolder.m (-supportsSubFolders): overriden method to return YES. diff --git a/OpenChange/GCSSpecialQueries+OpenChange.m b/OpenChange/GCSSpecialQueries+OpenChange.m index aa336bf99..914fe6227 100644 --- a/OpenChange/GCSSpecialQueries+OpenChange.m +++ b/OpenChange/GCSSpecialQueries+OpenChange.m @@ -35,6 +35,8 @@ @implementation GCSSpecialQueries (OpenChangeHelpers) +/* FIXME: c_parent_path should be indexed */ + - (NSString *) createOpenChangeFSTableWithName: (NSString *) tableName { [self subclassResponsibility: _cmd]; @@ -51,6 +53,7 @@ static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (" @" c_path VARCHAR(255) PRIMARY KEY," + @" c_parent_path VARCHAR(255)," @" c_type SMALLINT NOT NULL," @" c_creationdate INT4 NOT NULL," @" c_lastmodified INT4 NOT NULL," @@ -70,6 +73,7 @@ static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (" @" c_path VARCHAR(255) PRIMARY KEY," + @" c_parent_path VARCHAR(255)," @" c_type TINYINT NOT NULL," @" c_creationdate INT NOT NULL," @" c_lastmodified INT NOT NULL," @@ -89,6 +93,7 @@ static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (" @" c_path VARCHAR2(255) PRIMARY KEY," + @" c_parent_path VARCHAR2(255)," @" c_type SMALLINT NOT NULL," @" c_creationdate INT4 NOT NULL," @" c_lastmodified INT4 NOT NULL," diff --git a/OpenChange/SOGoMAPIDBFolder.m b/OpenChange/SOGoMAPIDBFolder.m index ddd6086a6..2607eb1aa 100644 --- a/OpenChange/SOGoMAPIDBFolder.m +++ b/OpenChange/SOGoMAPIDBFolder.m @@ -107,7 +107,7 @@ Class SOGoMAPIDBObjectK = Nil; NSMutableString *path; path = [self path]; - [path appendFormat: @"/%@", childName]; + [path appendFormat: @"/%@", childName]; return path; } @@ -153,9 +153,8 @@ Class SOGoMAPIDBObjectK = Nil; [sql appendFormat: @"SELECT * FROM %@", [self tableName]]; whereClause = [NSMutableArray arrayWithCapacity: 2]; - childPathPrefix = [NSString stringWithFormat: @"%@/", [self path]]; - [whereClause addObject: [NSString stringWithFormat: @"c_path LIKE '%@%%'", - childPathPrefix]]; + [whereClause addObject: [NSString stringWithFormat: @"c_parent_path = '%@'", + [self path]]]; [whereClause addObject: [NSString stringWithFormat: @"c_type = %d", type]]; if (!includeDeleted) [whereClause addObject: @"c_deleted = 0"]; @@ -163,6 +162,8 @@ Class SOGoMAPIDBObjectK = Nil; [sql appendFormat: @" WHERE %@", [whereClause componentsJoinedByString: @" AND "]]; + childPathPrefix = [NSString stringWithFormat: @"%@/", [self path]]; + /* results */ records = [self performSQLQuery: sql]; if (records) diff --git a/OpenChange/SOGoMAPIDBObject.m b/OpenChange/SOGoMAPIDBObject.m index f5014dd52..e085440a3 100644 --- a/OpenChange/SOGoMAPIDBObject.m +++ b/OpenChange/SOGoMAPIDBObject.m @@ -391,7 +391,7 @@ static EOAttribute *textColumn = nil; EOAdaptor *adaptor; EOAdaptorChannel *channel; NSInteger creationDateValue, lastModifiedValue, deletedValue; - NSString *tableName, *pathValue, *propsValue; + NSString *tableName, *pathValue, *parentPathValue, *propsValue; NSException *result; if (!initialized) @@ -440,14 +440,18 @@ static EOAttribute *textColumn = nil; { ASSIGN (creationDate, now); creationDateValue = (NSInteger) [creationDate timeIntervalSince1970]; + parentPathValue = [adaptor formatValue: [container path] + forAttribute: textColumn]; + if (!parentPathValue) + parentPathValue = @"NULL"; sql = [NSString stringWithFormat: (@"INSERT INTO %@" - @" (c_path, c_type, c_creationdate, c_lastmodified," + @" (c_path, c_parent_path, c_type, c_creationdate, c_lastmodified," @" c_deleted, c_version, c_content)" - @" VALUES (%@, %d, %d, %d, 0, 0, %@" + @" VALUES (%@, %@, %d, %d, %d, 0, 0, %@" @")"), tableName, - pathValue, objectType, + pathValue, parentPathValue, objectType, creationDateValue, lastModifiedValue, propsValue]; isNew = NO;