aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableSource.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-03-22 17:22:58 +0000
committerstuconnolly <stuart02@gmail.com>2010-03-22 17:22:58 +0000
commit3934c544c9b2e2f77227864ad9c91bd8bb1077fe (patch)
tree38b30bea2ab19a1c88db94514aa7798a88c73c1d /Source/TableSource.m
parentdb2d9565c996e206d82a441cfd8e60627f0eab6d (diff)
downloadsequelpro-3934c544c9b2e2f77227864ad9c91bd8bb1077fe.tar.gz
sequelpro-3934c544c9b2e2f77227864ad9c91bd8bb1077fe.tar.bz2
sequelpro-3934c544c9b2e2f77227864ad9c91bd8bb1077fe.zip
When adding an index, after splitting the list of supplied columns strip leading and trailing whitespace rather than checking whether the first character is empty. This accommodates lists of fields which have more than one leading and trailing empty characters and fixes the following exception: http://log.sequelpro.com/view/70.
Diffstat (limited to 'Source/TableSource.m')
-rw-r--r--Source/TableSource.m26
1 files changed, 10 insertions, 16 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m
index da5577de..5f5b0119 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -1689,16 +1689,14 @@ would result in a position change.
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSString *indexName;
- NSArray *indexedColumns;
- NSMutableArray *tempIndexedColumns = [NSMutableArray array];
- NSString *string;
-
// Check whether a save of the current fields row is required.
if (![self saveRowOnDeselect]) return;
if (![[indexedColumnsField stringValue] isEqualToString:@""]) {
+ NSString *indexName = @"";
+ NSMutableArray *tempIndexedColumns = [[NSMutableArray alloc] init];
+
if ([[indexNameField stringValue] isEqualToString:@"PRIMARY"]) {
indexName = @"";
}
@@ -1706,18 +1704,12 @@ would result in a position change.
indexName = ([[indexNameField stringValue] isEqualToString:@""]) ? @"" : [[indexNameField stringValue] backtickQuotedString];
}
- indexedColumns = [[indexedColumnsField stringValue] componentsSeparatedByString:@","];
+ NSArray *indexedColumns = [[indexedColumnsField stringValue] componentsSeparatedByString:@","];
- NSEnumerator *enumerator = [indexedColumns objectEnumerator];
-
- while ((string = [enumerator nextObject]))
- {
- if (([string characterAtIndex:0] == ' ')) {
- [tempIndexedColumns addObject:[string substringWithRange:NSMakeRange(1, ([string length] - 1))]];
- }
- else {
- [tempIndexedColumns addObject:[NSString stringWithString:string]];
- }
+ // For each column strip leading and trailing whitespace and add it to the temp array
+ for (NSString *column in indexedColumns)
+ {
+ [tempIndexedColumns addObject:[column stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
}
// Execute the query
@@ -1735,6 +1727,8 @@ would result in a position change.
[tablesListInstance setStatusRequiresReload:YES];
[self loadTable:selectedTable];
}
+
+ [tempIndexedColumns release];
}
[tableDocumentInstance endTask];