diff options
author | rowanbeentje <rowan@beent.je> | 2009-07-09 23:34:33 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-07-09 23:34:33 +0000 |
commit | 98cbee9825fc5711fcb228b4ab24a3729b409358 (patch) | |
tree | 899c3ff327f80bfb8ce4880302f0ba8840f0e0af /Source | |
parent | e1602ee0f7ae46a52aac8f18e5752eae8bb72664 (diff) | |
download | sequelpro-98cbee9825fc5711fcb228b4ab24a3729b409358.tar.gz sequelpro-98cbee9825fc5711fcb228b4ab24a3729b409358.tar.bz2 sequelpro-98cbee9825fc5711fcb228b4ab24a3729b409358.zip |
- Correctly display errors that occur when editing rows, and ensure the row isn't deselected to prevent accidental loss of entered data
Diffstat (limited to 'Source')
-rw-r--r-- | Source/TableContent.m | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m index 3ed6dd43..11c09525 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1567,9 +1567,10 @@ } [mySQLConnection queryString:queryString]; [fieldValues release]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; - // If no rows have been changed, show error if appropriate. - if ( ![mySQLConnection affectedRows] ) { + // If no rows have been changed, show error if appropriate. + if ( ![mySQLConnection affectedRows] && ![mySQLConnection getLastErrorMessage] && ![[mySQLConnection getLastErrorMessage] length]) { if ( [prefs boolForKey:@"ShowNoAffectedRowsError"] ) { NSBeginAlertSheet(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")); @@ -1581,7 +1582,6 @@ isEditingNewRow = NO; currentlyEditingRow = -1; [[SPQueryConsole sharedQueryConsole] showErrorInConsole:[NSString stringWithFormat:NSLocalizedString(@"/* WARNING %@ No rows have been affected */\n", @"warning shown in the console when no rows have been affected after writing to the db"), currentTime]]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; return YES; // On success... @@ -1635,16 +1635,13 @@ } } currentlyEditingRow = -1; - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; return YES; // Report errors which have occurred } else { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addrow", - [NSString stringWithFormat:NSLocalizedString(@"Couldn't write row.\nMySQL said: %@", @"message of panel when error while adding row to db"), [mySQLConnection getLastErrorMessage]]); - - [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + NSBeginAlertSheet(NSLocalizedString(@"Couldn't write row", @"Couldn't write row error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addrow", + [NSString stringWithFormat:NSLocalizedString(@"MySQL said:\n\n%@", @"message of panel when error while adding row to db"), [mySQLConnection getLastErrorMessage]]); return NO; } } |