Skip to content

Commit

Permalink
Merge pull request #698 from Sequel-Ace/fix-backtickQuotedString-crash
Browse files Browse the repository at this point in the history
 #fixed SPTableCopy _createTableStatementFor:inDatabase crash
  • Loading branch information
Kaspik committed Dec 27, 2020
2 parents f2899dd + fa91f4d commit b7b93ad
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Source/Other/DatabaseActions/SPTableCopy.m
Expand Up @@ -31,6 +31,7 @@
#import "SPTableCopy.h"

#import <SPMySQL/SPMySQL.h>
#import <FirebaseCrashlytics/FirebaseCrashlytics.h>

@interface SPTableCopy ()

Expand Down Expand Up @@ -142,6 +143,21 @@ - (BOOL)moveTable:(NSString *)tableName from:(NSString *)sourceDatabase to:(NSSt

- (NSString *)_createTableStatementFor:(NSString *)tableName inDatabase:(NSString *)sourceDatabase
{

if([tableName respondsToSelector:@selector(backtickQuotedString)] == NO || [sourceDatabase respondsToSelector:@selector(backtickQuotedString)] == NO){
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: @"_createTableStatementFor: tableName or sourceDatabase does not respond to selector: backtickQuotedString",
@"tableName":tableName.class,
@"sourceDatabase":sourceDatabase.class
};

CLS_LOG(@"_createTableStatementFor: tableName or sourceDatabase does not respond to selector: backtickQuotedString");
SPLog(@"_createTableStatementFor: tableName or sourceDatabase does not respond to selector: backtickQuotedString");
[FIRCrashlytics.crashlytics recordError:[NSError errorWithDomain:@"database" code:9 userInfo:userInfo]];

return nil;
}

NSString *showCreateTableStatment = [NSString stringWithFormat:@"SHOW CREATE TABLE %@.%@", [sourceDatabase backtickQuotedString], [tableName backtickQuotedString]];

SPMySQLResult *result = [connection queryString:showCreateTableStatment];
Expand Down

0 comments on commit b7b93ad

Please sign in to comment.