Skip to content

Commit

Permalink
Merge branch 'main' into FK_otherDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason-Morcos committed Jan 23, 2021
2 parents 871e8d3 + 3083682 commit 8dd1887
Show file tree
Hide file tree
Showing 40 changed files with 7,200 additions and 6,194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
177916A21E88733000EE3043 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 177916A01E88733000EE3043 /* LICENSE */; };
17E3A57B1885A286009CF372 /* SPMySQLDataTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E3A5791885A286009CF372 /* SPMySQLDataTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
17E3A57C1885A286009CF372 /* SPMySQLDataTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E3A57A1885A286009CF372 /* SPMySQLDataTypes.m */; };
1A96314625B9CE6600BF2E91 /* SPMySQLArrayAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A96314425B9CE6600BF2E91 /* SPMySQLArrayAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
1A96314725B9CE6600BF2E91 /* SPMySQLArrayAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A96314525B9CE6600BF2E91 /* SPMySQLArrayAdditions.m */; };
1A96314E25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A96314C25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.m */; };
1A96314F25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A96314D25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
269BA7EB249FDC97005E4896 /* libcrypto.1.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 269BA7EA249FDC97005E4896 /* libcrypto.1.1.dylib */; };
269BA7ED249FDCB1005E4896 /* libssl.1.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 269BA7EC249FDCB1005E4896 /* libssl.1.1.dylib */; };
26F0BF1124A0052B00A43B20 /* libcrypto.1.1.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 269BA7EA249FDC97005E4896 /* libcrypto.1.1.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
Expand Down Expand Up @@ -128,6 +132,10 @@
177916A11E88733000EE3043 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
17E3A5791885A286009CF372 /* SPMySQLDataTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPMySQLDataTypes.h; path = Source/SPMySQLDataTypes.h; sourceTree = "<group>"; };
17E3A57A1885A286009CF372 /* SPMySQLDataTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPMySQLDataTypes.m; path = Source/SPMySQLDataTypes.m; sourceTree = "<group>"; };
1A96314425B9CE6600BF2E91 /* SPMySQLArrayAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPMySQLArrayAdditions.h; path = Source/SPMySQLArrayAdditions.h; sourceTree = "<group>"; };
1A96314525B9CE6600BF2E91 /* SPMySQLArrayAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPMySQLArrayAdditions.m; path = Source/SPMySQLArrayAdditions.m; sourceTree = "<group>"; };
1A96314C25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPMySQLMutableDictionaryAdditions.m; path = Source/SPMySQLMutableDictionaryAdditions.m; sourceTree = "<group>"; };
1A96314D25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPMySQLMutableDictionaryAdditions.h; path = Source/SPMySQLMutableDictionaryAdditions.h; sourceTree = "<group>"; };
269BA7EA249FDC97005E4896 /* libcrypto.1.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libcrypto.1.1.dylib; sourceTree = "<group>"; };
269BA7EC249FDCB1005E4896 /* libssl.1.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libssl.1.1.dylib; sourceTree = "<group>"; };
32DBCF5E0370ADEE00C91783 /* SPMySQLFramework_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPMySQLFramework_Prefix.pch; path = Source/SPMySQLFramework_Prefix.pch; sourceTree = "<group>"; };
Expand Down Expand Up @@ -469,6 +477,10 @@
58C009D214E31D1300AC489A /* Category Additions */ = {
isa = PBXGroup;
children = (
1A96314D25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.h */,
1A96314C25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.m */,
1A96314425B9CE6600BF2E91 /* SPMySQLArrayAdditions.h */,
1A96314525B9CE6600BF2E91 /* SPMySQLArrayAdditions.m */,
58C009D314E31D3800AC489A /* SPMySQLStringAdditions.h */,
58C009D414E31D3800AC489A /* SPMySQLStringAdditions.m */,
);
Expand Down Expand Up @@ -499,6 +511,7 @@
58428E0014BA5FAE000F8438 /* SPMySQLConnection.h in Headers */,
51515AB625712540009E8B58 /* plugin_auth_common.h in Headers */,
584294E414CB8002000F8438 /* SPMySQLConstants.h in Headers */,
1A96314625B9CE6600BF2E91 /* SPMySQLArrayAdditions.h in Headers */,
51515ABF25712540009E8B58 /* errmsg.h in Headers */,
51515AB225712540009E8B58 /* mysqlx_version.h in Headers */,
51515AAD25712540009E8B58 /* binary_log_types.h in Headers */,
Expand All @@ -513,6 +526,7 @@
584F16A81752911200D150A6 /* SPMySQLStreamingResultStore.h in Headers */,
51515AB025712540009E8B58 /* mysql_time.h in Headers */,
51515AB925712540009E8B58 /* psi_base.h in Headers */,
1A96314F25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.h in Headers */,
51515AB525712540009E8B58 /* mysql_com.h in Headers */,
5884127714CC63830078027F /* SPMySQL.h in Headers */,
588412A814CC7A4D0078027F /* Locking.h in Headers */,
Expand Down Expand Up @@ -705,6 +719,7 @@
5884142814CCF5190078027F /* Conversion.m in Sources */,
5884159514D1A6880078027F /* Querying & Preparation.m in Sources */,
5884159414D1A6760078027F /* Locking.m in Sources */,
1A96314E25B9CE9900BF2E91 /* SPMySQLMutableDictionaryAdditions.m in Sources */,
17E3A57C1885A286009CF372 /* SPMySQLDataTypes.m in Sources */,
5884165614D2306A0078027F /* SPMySQLResult.m in Sources */,
580A331F14D75CF7000D6933 /* SPMySQLGeometryData.m in Sources */,
Expand All @@ -715,6 +730,7 @@
58C00AB614E4892E00AC489A /* Delegate & Proxy.m in Sources */,
58C00BD214E7459600AC489A /* Databases & Tables.m in Sources */,
586A99FC14F02E21007F82BF /* SPMySQLStreamingResult.m in Sources */,
1A96314725B9CE6600BF2E91 /* SPMySQLArrayAdditions.m in Sources */,
586AA16814F30C5F007F82BF /* Convenience Methods.m in Sources */,
584D812F15057ECD00F24774 /* SPMySQLKeepAliveTimer.m in Sources */,
584D82561509775000F24774 /* Copying.m in Sources */,
Expand Down
27 changes: 27 additions & 0 deletions Frameworks/SPMySQLFramework/Source/SPMySQLArrayAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// SPMySQLArrayAdditions.h
// Sequel Ace
//
// Created by James on 21/1/2021.
// Copyright © 2021 Sequel-Ace. All rights reserved.
//


@interface NSArray (SPMySQLArrayAdditions)

/**
* Variant of objectAtIndex: that avoids the "index out of bounds" exception by
* just returning nil instead.
*
* @warning This method is NOT thread-safe.
* @param idx An index
* @return The object located at index or nil.
*/
- (nullable id)SPsafeObjectAtIndex:(NSUInteger)idx;
@end

@interface NSMutableArray (SPMutableArrayAdditions)

- (void)SPsafeAddObject:(nullable id)obj;

@end
28 changes: 28 additions & 0 deletions Frameworks/SPMySQLFramework/Source/SPMySQLArrayAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// SPMySQLArrayAdditions.m
// Sequel Ace
//
// Created by James on 21/1/2021.
// Copyright © 2021 Sequel-Ace. All rights reserved.
//

#import "SPMySQLArrayAdditions.h"

@implementation NSArray (SPMySQLArrayAdditions)

- (nullable id)SPsafeObjectAtIndex:(NSUInteger)idx
{
return idx < self.count ? [self objectAtIndex:idx] : nil;
}

@end

@implementation NSMutableArray (SPMySQLMutableArrayAdditions)

- (void)SPsafeAddObject:(nullable id)obj{
if (obj != nil) {
[self addObject:obj];
}
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#import "Databases & Tables.h"
#import "SPMySQL Private APIs.h"
#import "SPMySQLStringAdditions.h"
#import "SPMySQLArrayAdditions.h"

@implementation SPMySQLConnection (Databases_and_Tables)

Expand Down Expand Up @@ -127,7 +128,7 @@ - (NSArray *)databasesLike:(NSString *)nameLikeString
if (![self queryErrored]) {
databaseList = [NSMutableArray arrayWithCapacity:(NSUInteger)[databaseResult numberOfRows]];
for (NSArray *dbRow in databaseResult) {
[databaseList addObject:[dbRow objectAtIndex:0]];
[databaseList SPsafeAddObject:[dbRow SPsafeObjectAtIndex:0]];
}
}

Expand Down Expand Up @@ -212,7 +213,7 @@ - (NSArray *)tablesLike:(NSString *)nameLikeString fromDatabase:(NSString *)aDat
if (![self queryErrored]) {
tableList = [NSMutableArray arrayWithCapacity:(NSUInteger)[tableResult numberOfRows]];
for (NSArray *tableRow in tableResult) {
[tableList addObject:[tableRow objectAtIndex:0]];
[tableList SPsafeAddObject:[tableRow SPsafeObjectAtIndex:0]];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#import "Max Packet Size.h"
#import "SPMySQL Private APIs.h"
#import "SPMySQLArrayAdditions.h"

@implementation SPMySQLConnection (Max_Packet_Size)

Expand Down Expand Up @@ -108,7 +109,7 @@ - (NSInteger)_queryMaxAllowedPacketWithSQL:(NSString *)query resultInColumn:(NSU
[result setReturnDataAsStrings:YES];

// Get the maximum size string
NSString *maxQuerySizeString = [[result getRowAsArray] objectAtIndex:colIdx];
NSString *maxQuerySizeString = [[result getRowAsArray] SPsafeObjectAtIndex:colIdx];

NSInteger _maxQuerySize = maxQuerySizeString ? [maxQuerySizeString integerValue] : 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#import "SPMySQLConnection.h"
#import "SPMySQL Private APIs.h"
#import "SPMySQLArrayAdditions.h"

@implementation SPMySQLConnection (Querying_and_Preparation)

Expand Down Expand Up @@ -439,7 +440,7 @@ - (NSArray *)getAllRowsFromQuery:(NSString *)theQueryString
*/
- (id)getFirstFieldFromQuery:(NSString *)theQueryString
{
return [[[self queryString:theQueryString] getRowAsArray] objectAtIndex:0];
return [[[self queryString:theQueryString] getRowAsArray] SPsafeObjectAtIndex:0];
}

#pragma mark -
Expand Down
4 changes: 3 additions & 1 deletion Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <pthread.h>
#include <SystemConfiguration/SCNetworkReachability.h>
#import "SPMySQLUtilities.h"
#import "SPMySQLArrayAdditions.h"
#import "SPMySQLMutableDictionaryAdditions.h"

@interface SPMySQLConnection ()

Expand Down Expand Up @@ -1128,7 +1130,7 @@ - (void)_updateConnectionVariables
[theResult setDefaultRowReturnType:SPMySQLResultRowAsArray];
NSMutableDictionary *variables = [NSMutableDictionary new];
for (NSArray *variableRow in theResult) {
[variables setObject:[variableRow objectAtIndex:1] forKey:[variableRow objectAtIndex:0]];
[variables SPsafeSetObject:[variableRow SPsafeObjectAtIndex:1] forKey:[variableRow SPsafeObjectAtIndex:0]];
}

// Get the connection encoding. Although a specific encoding may have been requested on
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// SPMySQLMutableDictionaryAdditions.h
// Sequel Ace
//
// Created by James on 21/1/2021.
// Copyright © 2021 Sequel-Ace. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSMutableDictionary (SPMySQLMutableDictionaryAdditions)

- (void)SPsafeSetObject:(id)obj forKey:(id)key;
- (void)SPsafeRemoveObjectForKey:(nullable id)key;

@end

@interface NSDictionary (SPMySQLDictionaryAdditions)

/*If obj or key are nil, does nothing. No exception thrown.*/
- (id)SPsafeObjectForKey:(id)key;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// SPMySQLMutableDictionaryAdditions.m
// Sequel Ace
//
// Created by James on 21/1/2021.
// Copyright © 2021 Sequel-Ace. All rights reserved.
//

#import "SPMySQLMutableDictionaryAdditions.h"

@implementation NSMutableDictionary (SPMySQLMutableDictionaryAdditions)

#pragma mark -
#pragma mark NSMutableDictionary methods

- (void)SPsafeSetObject:(id)obj forKey:(id)key {
if (obj != nil & key != nil) {
[self setObject:obj forKey:key];
}
}

- (void)SPsafeRemoveObjectForKey:(nullable id)key{
id object = [self SPsafeObjectForKey:key];
if (object != nil && object != [NSNull null]) {
[self removeObjectForKey:key];
}
}

@end

@implementation NSDictionary (SPMySQLDictionaryAdditions)

#pragma mark -
#pragma mark NSDictionary method

- (id)SPsafeObjectForKey:(id)key {
id object = [self objectForKey:key];
if (object != nil && object == [NSNull null]) {
return nil;
}
return object;
}

@end
2 changes: 2 additions & 0 deletions Interfaces/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,8 @@ CQ
<customObject id="213" userLabel="SPAppController" customClass="SPAppController">
<connections>
<outlet property="staleBookmarkHelpView" destination="Ipz-ua-fp5" id="psg-8l-YU5"/>
<outlet property="staleBookmarkTextField" destination="Bea-mS-nZN" id="m3E-QZ-KCA"/>
<outlet property="staleBookmarkTextFieldCell" destination="jQo-Yb-Hvj" id="8Ts-TE-F5t"/>
</connections>
</customObject>
<menu id="956" userLabel="Dock Menu">
Expand Down
9 changes: 9 additions & 0 deletions Resources/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3177,6 +3177,15 @@
/* Stale Bookmarks error title */
"Stale Bookmarks" = "Stale Bookmarks";

/* App Sandbox info link text */
"App Sandbox Info" = "App Sandbox Info";

/* error while selecting file title */
"File Selection Error" = "File Selection Error";

/* error while selecting file message */
"The selected file is not a valid file.\n\nPlease try again.\n\nClass: %@" = "The selected file is not a valid file.\n\nPlease try again.\n\nClass: %@";

/* Question to user to see if they would like to re-request access */
"You have stale secure bookmarks:\n\n%@\n\nWould you like to re-request access now?" = "You have stale secure bookmarks:\n\n%@\n\nWould you like to re-request access now?";

Expand Down
6 changes: 0 additions & 6 deletions Source/Controllers/DataControllers/SPDatabaseStructure.m
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,6 @@ - (void)queryDbStructureWithUserInfo:(NSDictionary *)userInfo
// Loop through the fields, extracting details for each
for (NSArray *row in theResult) {

if (row.count < 7){
CLS_LOG(@"row count < 7. the row: %@", row);
SPLog(@"row count < 7. the row: %@", row);
[FIRCrashlytics.crashlytics recordError:[NSError errorWithDomain:@"database" code:7 userInfo:userInfo]];
}

NSString *field = [row safeObjectAtIndex:0];
NSString *type = [row safeObjectAtIndex:1];
NSString *type_display = [type stringByReplacingOccurrencesOfRegex:@"\\(.*?,.*?\\)" withString:@"(…)"];
Expand Down
9 changes: 9 additions & 0 deletions Source/Controllers/DataControllers/SPTableData.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#import "SPServerSupport.h"
#import "SPFunctions.h"

@import Firebase;

#import "sequel-ace-Swift.h"

#import <pthread.h>
Expand Down Expand Up @@ -935,18 +937,25 @@ - (NSDictionary *) informationForView:(NSString *)viewName
*/
- (BOOL)updateStatusInformationForCurrentTable
{

SPLog(@"updateStatusInformationForCurrentTable called");

pthread_mutex_lock(&dataProcessingLock);

BOOL changeEncoding = ![[mySQLConnection encoding] hasPrefix:@"utf8"];

// Catch unselected tables and return false
if (![tableListInstance tableName]) {
pthread_mutex_unlock(&dataProcessingLock);
SPLog(@"No table selected, returning");
CLS_LOG(@"No table selected, returning");
return NO;
}

// Ensure queries are run as UTF8mb4
if (changeEncoding) {
SPLog(@"changeEncoding to utf8mb4 from utf8");
CLS_LOG(@"changeEncoding to utf8mb4 from utf8");
[mySQLConnection storeEncodingForRestoration];
[mySQLConnection setEncoding:@"utf8mb4"];
}
Expand Down
35 changes: 25 additions & 10 deletions Source/Controllers/DataExport/SPExportController.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#import "SPExportFileNameTokenObject.h"
#import "SPDatabaseDocument.h"
#import "SPThreadAdditions.h"
#import "SPPreferenceController.h"
#import "SPGeneralPreferencePane.h"
#import "SPAppController.h"
#import "SPCustomQuery.h"
#import "SPCSVExporter.h"
#import "SPSQLExporter.h"
Expand Down Expand Up @@ -644,21 +647,33 @@ - (IBAction)changeExportOutputPath:(id)sender

[self->exportPathField setStringValue:path];

NSMutableString *classStr = [NSMutableString string];
[classStr appendStringOrNil:NSStringFromClass(self->changeExportOutputPathPanel.URL.class)];

SPLog(@"self->changeExportOutputPathPanel.URL.class: %@", classStr);

// check it's really a URL
if(![self->changeExportOutputPathPanel.URL isKindOfClass:[NSURL class]]){
NSMutableString *classStr = [NSMutableString string];
[classStr appendStringOrNil:NSStringFromClass(self->changeExportOutputPathPanel.URL.class)];

SPLog(@"self->keySelectionPanel.URL is not a URL: %@", classStr);
CLS_LOG(@"self->keySelectionPanel.URL is not a URL: %@", classStr);
// JCS - should we stop here?
SPLog(@"self->changeExportOutputPathPanel.URL is not a valid URL: %@", classStr);
CLS_LOG(@"self->changeExportOutputPathPanel.URL is not a valid URL: %@", classStr);

NSView *helpView = [[[SPAppDelegate preferenceController] generalPreferencePane] modifyAndReturnBookmarkHelpView];

NSString *alertMessage = [NSString stringWithFormat:NSLocalizedString(@"The selected file is not a valid file.\n\nPlease try again.\n\nClass: %@", @"error while selecting file message"),
classStr];

[NSAlert createAccessoryWarningAlertWithTitle:NSLocalizedString(@"File Selection Error", @"error while selecting file message") message:alertMessage accessoryView:helpView callback:^{

NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: @"self->changeExportOutputPathPanel.URL is not a URL",
@"class": classStr
};
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: @"self->changeExportOutputPathPanel.URL is not a valid URL",
@"func": [NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__],
@"class": classStr
};

[FIRCrashlytics.crashlytics recordError:[NSError errorWithDomain:@"chooseFile" code:1 userInfo:userInfo]];
SPLog(@"userInfo: %@", userInfo);
[FIRCrashlytics.crashlytics recordError:[NSError errorWithDomain:@"chooseFileExportController" code:1 userInfo:userInfo]];
}];
}
else{
// this needs to be read-write
Expand Down

0 comments on commit 8dd1887

Please sign in to comment.