aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-11-20 01:12:14 +0000
committerstuconnolly <stuart02@gmail.com>2009-11-20 01:12:14 +0000
commitdcaa35d218ad66e61eeba0bac5a767f9a206f0b3 (patch)
treef991b2791b34e0a806c0504ca03ac105dfc5142c /Source/TableContent.m
parentf5bbd06bdfb991fec371e9e56f8a52cb6b2b2ae4 (diff)
downloadsequelpro-dcaa35d218ad66e61eeba0bac5a767f9a206f0b3.tar.gz
sequelpro-dcaa35d218ad66e61eeba0bac5a767f9a206f0b3.tar.bz2
sequelpro-dcaa35d218ad66e61eeba0bac5a767f9a206f0b3.zip
Delay the releasing of the createTableSyntax variable in SPTableData until we are about the replace it to prevent threading issues. Also, in fieldListForQuery check that dataColumns array is not empty before constructing the field list as well as only obtaining the table's columns if the field list is going to be built in the first place.
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m19
1 files changed, 13 insertions, 6 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 58f2bc35..60a7ce4a 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -890,12 +890,14 @@
- (IBAction)reloadTable:(id)sender
{
[tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Reloading data...", @"Reloading data task description")];
+
if ([NSThread isMainThread]) {
[NSThread detachNewThreadSelector:@selector(reloadTableTask) toTarget:self withObject:nil];
} else {
[self reloadTableTask];
}
}
+
- (void)reloadTableTask
{
NSAutoreleasePool *reloadPool = [[NSAutoreleasePool alloc] init];
@@ -913,6 +915,7 @@
[self loadTable:selectedTable];
[tableDocumentInstance endTask];
+
[reloadPool drain];
}
@@ -1832,21 +1835,25 @@
{
NSInteger i;
NSMutableArray *fields = [NSMutableArray array];
- NSArray *columnNames = [tableDataInstance columnNames];
- if ( [prefs boolForKey:SPLoadBlobsAsNeeded] ) {
- for ( i = 0 ; i < [columnNames count] ; i++ ) {
+ if (([prefs boolForKey:SPLoadBlobsAsNeeded]) && ([dataColumns count] > 0)) {
+
+ NSArray *columnNames = [tableDataInstance columnNames];
+
+ for (i = 0 ; i < [columnNames count]; i++)
+ {
if (![tableDataInstance columnIsBlobOrText:[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"]] ) {
[fields addObject:[NSArrayObjectAtIndex(columnNames, i) backtickQuotedString]];
- } else {
-
+ }
+ else {
// For blob/text fields, select a null placeholder so the column count is still correct
[fields addObject:@"NULL"];
}
}
return [fields componentsJoinedByString:@","];
- } else {
+ }
+ else {
return @"*";
}
}