aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPDatabaseCopy.m5
-rw-r--r--Source/SPDatabaseRename.m5
-rw-r--r--Source/TableDocument.m20
-rw-r--r--UnitTests/SPDatabaseCopyTest.m2
-rw-r--r--UnitTests/SPDatabaseRenameTest.m2
5 files changed, 21 insertions, 13 deletions
diff --git a/Source/SPDatabaseCopy.m b/Source/SPDatabaseCopy.m
index 5f0c8fe8..2d5f92c3 100644
--- a/Source/SPDatabaseCopy.m
+++ b/Source/SPDatabaseCopy.m
@@ -63,7 +63,7 @@
}
DLog(@"list of found tables of source db: %@", tables);
- [self createDatabase:targetDatabaseName];
+ BOOL success = [self createDatabase:targetDatabaseName];
SPTableCopy *dbActionTableCopy = [[SPTableCopy alloc] init];
[dbActionTableCopy setConnection:connection];
@@ -72,8 +72,11 @@
from:sourceDatabaseName
to:targetDatabaseName
withContent:copyWithContent]) {
+ } else {
+ success = NO;
}
}
+ return success;
}
- (BOOL) createDatabase: (NSString *)newDatabaseName {
diff --git a/Source/SPDatabaseRename.m b/Source/SPDatabaseRename.m
index 448b2690..26a983e5 100644
--- a/Source/SPDatabaseRename.m
+++ b/Source/SPDatabaseRename.m
@@ -63,7 +63,7 @@
}
DLog(@"list of found tables of source db: %@", tables);
- [self createDatabase:targetDatabaseName];
+ BOOL success = [self createDatabase:targetDatabaseName];
SPTableCopy *dbActionTableCopy = [[SPTableCopy alloc] init];
[dbActionTableCopy setConnection:connection];
@@ -71,6 +71,8 @@
if ([dbActionTableCopy moveTable:currentTable
from:sourceDatabaseName
to:targetDatabaseName]) {
+ } else {
+ success = FALSE;
}
}
tables = [connection listTablesFromDB:sourceDatabaseName];
@@ -83,6 +85,7 @@
@"delete database not empty error informative message"),
sourceDatabaseName]);
}
+ return success;
}
- (BOOL) createDatabase: (NSString *)newDatabaseName {
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 7b5c3d2f..ea071365 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -4150,12 +4150,13 @@
BOOL copyWithContent = [copyOnlyStructureButton state] == NSOffState;
- [dbActionCopy copyDatabaseFrom: [self database]
- to: [databaseCopyNameField stringValue]
- withContent: copyWithContent];
+ if ([dbActionCopy copyDatabaseFrom: [self database]
+ to: [databaseCopyNameField stringValue]
+ withContent: copyWithContent]) {
+ [selectedDatabase release];
+ selectedDatabase = [[NSString alloc] initWithString:[databaseCopyNameField stringValue]];
+ }
[dbActionCopy release];
- [selectedDatabase release];
- selectedDatabase = [[NSString alloc] initWithString:[databaseCopyNameField stringValue]];
[self setDatabases: self];
}
@@ -4168,11 +4169,12 @@
[dbActionRename setConnection: [self getConnection]];
[dbActionRename setMessageWindow: tableWindow];
- [dbActionRename renameDatabaseFrom: [self database]
- to: [databaseRenameNameField stringValue]];
+ if ([dbActionRename renameDatabaseFrom: [self database]
+ to: [databaseRenameNameField stringValue]]) {
+ [selectedDatabase release];
+ selectedDatabase = [[NSString alloc] initWithString:[databaseRenameNameField stringValue]];
+ }
[dbActionRename release];
- [selectedDatabase release];
- selectedDatabase = [[NSString alloc] initWithString:[databaseRenameNameField stringValue]];
[self setDatabases: self];
}
diff --git a/UnitTests/SPDatabaseCopyTest.m b/UnitTests/SPDatabaseCopyTest.m
index c9a37d3c..593989de 100644
--- a/UnitTests/SPDatabaseCopyTest.m
+++ b/UnitTests/SPDatabaseCopyTest.m
@@ -76,7 +76,7 @@
NSString *source = [[NSString alloc] initWithString:@"source_name"];
NSString *target = [[NSString alloc] initWithString:@"target_name"];
- [dbCopy copyDatabaseFrom:source to:target withContent:YES];
+ STAssertTrue([dbCopy copyDatabaseFrom:source to:target withContent:YES], @"method renameDatabaseFrom:to: is supposed to return YES");
[mockConnection verify];
[source release];
diff --git a/UnitTests/SPDatabaseRenameTest.m b/UnitTests/SPDatabaseRenameTest.m
index 4e17cbb8..51562db9 100644
--- a/UnitTests/SPDatabaseRenameTest.m
+++ b/UnitTests/SPDatabaseRenameTest.m
@@ -77,7 +77,7 @@
NSString *source = [[NSString alloc] initWithString:@"source_name"];
NSString *target = [[NSString alloc] initWithString:@"target_name"];
- [dbRename renameDatabaseFrom:source to:target];
+ STAssertTrue([dbRename renameDatabaseFrom:source to:target], @"method renameDatabaseFrom:to: is supposed to return YES");
[mockConnection verify];
[source release];