Skip to content

Commit

Permalink
Merge pull request #1421 from Sequel-Ace/possible-fix-for-invisible-c…
Browse files Browse the repository at this point in the history
…olumns-bug

Possible fix for crash on tables with invisible columns #fixed
  • Loading branch information
Jason-Morcos committed Mar 24, 2022
2 parents 6a23b4e + 0e57955 commit c25b64a
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2911,30 +2911,32 @@ - (BOOL)tableContainsBlobOrTextColumns
}

/**
* Returns a string controlling which fields to retrieve for a query. Returns * (all fields) if the preferences
* option dontShowBlob isn't set; otherwise, returns a comma-separated list of all non-blob/text fields.
* Returns a string controlling which fields to retrieve for a query. returns a comma-separated list of fields
*/
- (NSString *)fieldListForQuery
{
if (([prefs boolForKey:SPLoadBlobsAsNeeded]) && [dataColumns count]) {
if(![dataColumns count]) {
return @"*";
}

NSMutableArray *fields = [NSMutableArray arrayWithCapacity:[dataColumns count]];
BOOL tableHasBlobs = NO;
NSString *fieldName;
//Specifically list out columns to load invisible column data
NSMutableArray *fields = [NSMutableArray arrayWithCapacity:[dataColumns count]];
NSString *fieldName;
BOOL dontLoadTextAndBlobs = ([prefs boolForKey:SPLoadBlobsAsNeeded]);

for (NSDictionary* field in dataColumns)
if (![tableDataInstance columnIsBlobOrText:fieldName = [field objectForKey:@"name"]] )
[fields addObject:[fieldName backtickQuotedString]];
else {
// For blob/text fields, select a null placeholder so the column count is still correct
[fields addObject:@"NULL"];
tableHasBlobs = YES;
}
for (NSDictionary* field in dataColumns) {
fieldName = [field objectForKey:@"name"];

return (tableHasBlobs) ? [fields componentsJoinedByString:@", "] : @"*";
if (dontLoadTextAndBlobs && [tableDataInstance columnIsBlobOrText:fieldName]) {
// For blob/text fields, select a null placeholder so the column count is still correct
[fields addObject:@"NULL"];
continue;
}

}
return @"*";
[fields addObject:[fieldName backtickQuotedString]];
}

return [fields componentsJoinedByString:@", "];

}

Expand Down

0 comments on commit c25b64a

Please sign in to comment.