diff options
author | rowanbeentje <rowan@beent.je> | 2012-02-23 02:13:56 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-02-23 02:13:56 +0000 |
commit | 05f1612cbb7e33cf9135a346fc2505cc0e87e853 (patch) | |
tree | 785824be4e44a61389271343d958851fa4ff7dd0 /Source/SPTableRelations.m | |
parent | a889340b9cb1eca0d3ff022e8e6e2c718480bf44 (diff) | |
download | sequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.tar.gz sequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.tar.bz2 sequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.zip |
Warning: this branch commit is largely untested, and known to throw exceptions as database structure retrieval is currently missing!
Further work on SPMySQLFramework integration:
- Improve SPMySQL framework build settings including correct ppc builds and a Distribution configuration for the build distributions to match
- Add new convenience querying and result methods to the framework
- Amend Sequel Pro source to use the new SPMySQL.framework methods everywhere, replacing MCPKit methods where they differ and improving some functions
- Remove MCPKit from the source
- Fix a number of warnings on Release-style builds
Diffstat (limited to 'Source/SPTableRelations.m')
-rw-r--r-- | Source/SPTableRelations.m | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index eacdc8f6..44d05ee7 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -30,6 +30,7 @@ #import "SPTableView.h" #import "SPAlertSheets.h" #import "RegexKitLite.h" +#import "SPMySQL.h" static NSString *SPRemoveRelation = @"SPRemoveRelation"; @@ -177,12 +178,12 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; if ([connection queryErrored]) { // Retrieve the last connection error message. - NSString *errorText = [connection getLastErrorMessage]; + NSString *errorText = [connection lastErrorMessage]; // An error ID of 1005 indicates a foreign key error. These are thrown for many reasons, but the two // most common are 121 (name probably in use) and 150 (types don't exactly match). // Retrieve the InnoDB status and extract the most recent error for more helpful text. - if ([connection getLastErrorID] == 1005) { + if ([connection lastErrorID] == 1005) { NSString *statusText = [connection getFirstFieldFromQuery:@"SHOW INNODB STATUS"]; NSString *detailErrorString = [statusText stringByMatching:@"latest foreign key error\\s+-----*\\s+[0-9: ]*(.*?)\\s+-----" options:(RKLCaseless | RKLDotAll) inRange:NSMakeRange(0, [statusText length]) capture:1L error:NULL]; if (detailErrorString) { @@ -249,13 +250,10 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; // Get all InnoDB tables in the current database // TODO: MySQL 4 compatibility - MCPResult *result = [connection queryString:[NSString stringWithFormat:@"SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND engine = 'InnoDB' AND table_schema = %@", [[tableDocumentInstance database] tickQuotedString]]]; - - [result dataSeek:0]; - - for (NSUInteger i = 0; i < [result numOfRows]; i++) - { - [refTablePopUpButton addItemWithTitle:[[result fetchRowAsArray] objectAtIndex:0]]; + SPMySQLResult *result = [connection queryString:[NSString stringWithFormat:@"SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND engine = 'InnoDB' AND table_schema = %@", [[tableDocumentInstance database] tickQuotedString]]]; + [result setDefaultRowReturnType:SPMySQLResultRowAsArray]; + for (NSArray *eachRow in result) { + [refTablePopUpButton addItemWithTitle:[eachRow objectAtIndex:0]]; } // Reset other fields @@ -505,7 +503,7 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; SPBeginAlertSheet(NSLocalizedString(@"Unable to delete relation", @"error deleting relation message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], nil, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"The selected relation couldn't be deleted.\n\nMySQL said: %@", @"error deleting relation informative message"), [connection getLastErrorMessage]]); + [NSString stringWithFormat:NSLocalizedString(@"The selected relation couldn't be deleted.\n\nMySQL said: %@", @"error deleting relation informative message"), [connection lastErrorMessage]]); // Abort loop break; |