aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-03-25 01:13:12 +0000
committerrowanbeentje <rowan@beent.je>2010-03-25 01:13:12 +0000
commit32e858b26923b371a93e800687a13edf1254e445 (patch)
treeff2bac08381f0bd54e01c2f3f756c9fe5a2e2507 /Source/TableContent.m
parent5061643c1bf92a3583e4ede059951e1f17befac9 (diff)
downloadsequelpro-32e858b26923b371a93e800687a13edf1254e445.tar.gz
sequelpro-32e858b26923b371a93e800687a13edf1254e445.tar.bz2
sequelpro-32e858b26923b371a93e800687a13edf1254e445.zip
- Make [MCPConnection getLastErrorMessage] more consistent by always returning nil if no error occurred (previously a blank string was returned most of the time)
- Add a new (BOOL)[MCPConnection queryErrored] method, changing all error message checks to use it for clarity
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m14
1 files changed, 7 insertions, 7 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 51d9cbe3..0e2d1d9b 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -640,7 +640,7 @@
}
}
- if ([mySQLConnection queryCancelled] || ![[mySQLConnection getLastErrorMessage] isEqualToString:@""])
+ if ([mySQLConnection queryCancelled] || [mySQLConnection queryErrored])
isInterruptedLoad = YES;
else
isInterruptedLoad = NO;
@@ -1898,7 +1898,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
// If no rows have been changed, show error if appropriate.
- if ( ![mySQLConnection affectedRows] && ![mySQLConnection getLastErrorMessage] && ![[mySQLConnection getLastErrorMessage] length]) {
+ if ( ![mySQLConnection affectedRows] && ![mySQLConnection queryErrored] ) {
if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) {
SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db"));
@@ -1913,7 +1913,7 @@
return YES;
// On success...
- } else if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ } else if ( ![mySQLConnection queryErrored] ) {
isEditingRow = NO;
// New row created successfully
@@ -2160,7 +2160,7 @@
} else if ( [contextInfo isEqualToString:@"removeallrows"] ) {
if ( returnCode == NSAlertDefaultReturn ) {
[mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@", [selectedTable backtickQuotedString]]];
- if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ( ![mySQLConnection queryErrored] ) {
// Reset auto increment if suppression button was ticked
if([[sheet suppressionButton] state] == NSOnState)
@@ -2205,7 +2205,7 @@
// Get the number of rows in the table
MCPResult *r;
r = [mySQLConnection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [selectedTable backtickQuotedString]]];
- if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if (![mySQLConnection queryErrored]) {
NSArray *a = [r fetchRowAsArray];
if([a count])
numberOfRows = [[a objectAtIndex:0] integerValue];
@@ -2231,7 +2231,7 @@
[mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@ WHERE %@", [selectedTable backtickQuotedString], wherePart]];
// Check for errors
- if ( ![mySQLConnection affectedRows] || ![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ( ![mySQLConnection affectedRows] || [mySQLConnection queryErrored]) {
// If error delete that index from selectedRows for reloading table if
// "ReloadAfterRemovingRow" is disbaled
if(!reloadAfterRemovingRow)
@@ -2868,7 +2868,7 @@
previousTableRowsCount = tableRowsCount;
[self loadTableValues];
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"Couldn't sort table. MySQL said: %@", @"message of panel when sorting of table failed"), [mySQLConnection getLastErrorMessage]]);
[tableDocumentInstance endTask];