Monotone-Parent: 7bc959b7bdbff70b4793f01076b797130e83fd01

Monotone-Revision: 56f8217cb19f50d50429b4f745548b63bd418877

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-08-13T14:35:00
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2012-08-13 14:35:00 +00:00
parent b3c66a0996
commit a224a100db
4 changed files with 26 additions and 8 deletions
+8
View File
@@ -1,5 +1,13 @@
2012-08-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* 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.
@@ -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,"
+5 -4
View File
@@ -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)
+8 -4
View File
@@ -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;