aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/DBView.xib21
-rw-r--r--Source/SPDatabaseCopy.m14
-rw-r--r--Source/SPExportController.m2
-rw-r--r--Source/SPTableCopy.h15
-rw-r--r--Source/SPTableCopy.m36
5 files changed, 67 insertions, 21 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index 7f7fe455..0b8ee626 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -6664,7 +6664,7 @@
<string key="NSWindowContentMaxSize">{292, 132}</string>
<string key="NSWindowContentMinSize">{292, 132}</string>
<object class="NSView" key="NSWindowView" id="351046403">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -6673,6 +6673,7 @@
<int key="NSvFlags">256</int>
<string key="NSFrame">{{17, 98}, {258, 14}}</string>
<reference key="NSSuperview" ref="351046403"/>
+ <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="292220806">
<int key="NSCellFlags">68288064</int>
@@ -6689,6 +6690,7 @@
<int key="NSvFlags">258</int>
<string key="NSFrame">{{20, 72}, {252, 18}}</string>
<reference key="NSSuperview" ref="351046403"/>
+ <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="322980098">
<int key="NSCellFlags">-1804468671</int>
@@ -6704,8 +6706,9 @@
<object class="NSButton" id="61396236">
<reference key="NSNextResponder" ref="351046403"/>
<int key="NSvFlags">259</int>
- <string key="NSFrame">{{204, 13}, {77, 28}}</string>
+ <string key="NSFrame">{{176, 13}, {101, 28}}</string>
<reference key="NSSuperview" ref="351046403"/>
+ <reference key="NSWindow"/>
<int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="261586860">
@@ -6727,8 +6730,9 @@
<object class="NSButton" id="41421287">
<reference key="NSNextResponder" ref="351046403"/>
<int key="NSvFlags">259</int>
- <string key="NSFrame">{{136, 13}, {70, 28}}</string>
+ <string key="NSFrame">{{85, 13}, {93, 28}}</string>
<reference key="NSSuperview" ref="351046403"/>
+ <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="1011860722">
<int key="NSCellFlags">67239424</int>
@@ -6750,6 +6754,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 48}, {256, 18}}</string>
<reference key="NSSuperview" ref="351046403"/>
+ <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="852298622">
<int key="NSCellFlags">67239424</int>
@@ -6769,6 +6774,8 @@
</object>
</object>
<string key="NSFrameSize">{292, 132}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
<string key="NSMinSize">{292, 154}</string>
@@ -24296,12 +24303,14 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes>
<string>6938.IBPluginDependency</string>
<string>6938.ImportedFromIB2</string>
<string>6939.IBPluginDependency</string>
+ <string>6939.IBViewBoundsToFrameTransform</string>
<string>6939.ImportedFromIB2</string>
<string>6942.IBPluginDependency</string>
<string>6942.ImportedFromIB2</string>
<string>6943.IBPluginDependency</string>
<string>6943.ImportedFromIB2</string>
<string>6944.IBPluginDependency</string>
+ <string>6944.IBViewBoundsToFrameTransform</string>
<string>6944.ImportedFromIB2</string>
<string>6945.IBPluginDependency</string>
<string>6946.IBPluginDependency</string>
@@ -26015,12 +26024,18 @@ bGQgTmFtZQkgID0gQAoJCQkJICBMRU5HVEgoYEBgKSA+IEA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSAffineTransform">
+ <bytes key="NSTransformStruct">P4AAAL+AAABDRwAAwhwAAA</bytes>
+ </object>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSAffineTransform">
+ <bytes key="NSTransformStruct">P4AAAL+AAABCngAAwhwAAA</bytes>
+ </object>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
diff --git a/Source/SPDatabaseCopy.m b/Source/SPDatabaseCopy.m
index 66b6ba1b..c2371f3d 100644
--- a/Source/SPDatabaseCopy.m
+++ b/Source/SPDatabaseCopy.m
@@ -64,21 +64,15 @@
return NO;
}
- BOOL success = [self createDatabase:targetDatabaseName];
+ //abort here if database creation failed
+ if(![self createDatabase:targetDatabaseName])
+ return NO;
SPTableCopy *dbActionTableCopy = [[SPTableCopy alloc] init];
[dbActionTableCopy setConnection:connection];
- for (NSString *currentTable in tables) {
- if ([dbActionTableCopy copyTable:currentTable
- from:sourceDatabaseName
- to:targetDatabaseName
- withContent:copyWithContent]) {
- } else {
- success = NO;
- }
- }
+ BOOL success = [dbActionTableCopy copyTables:tables from:sourceDatabaseName to:targetDatabaseName withContent:copyWithContent];
[dbActionTableCopy release];
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index 0ff78c1f..b22d2c32 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -639,7 +639,7 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled";
// Check whether to save the export filename. Save it if it's not blank and contains at least one
// token - this suggests it's not a one-off filename
- if (![exportCustomFilenameTokenField stringValue]) {
+ if ([[exportCustomFilenameTokenField stringValue] length] < 1) {
[prefs removeObjectForKey:SPExportFilenameFormat];
} else {
BOOL saveFilename = NO;
diff --git a/Source/SPTableCopy.h b/Source/SPTableCopy.h
index 32eadcfc..56e1da8c 100644
--- a/Source/SPTableCopy.h
+++ b/Source/SPTableCopy.h
@@ -35,6 +35,7 @@
* @param name name of the table in the source database
* @param sourceDB name of the source database
* @param targetDB name of the target database
+ * @return YES on success, NO on any kind of error (unspecified)
*/
- (BOOL)copyTable:(NSString *)name from: (NSString *)sourceDB to: (NSString *)targetDB;
@@ -54,7 +55,21 @@
* @param sourceDB name of the source database
* @param targetDB name of the target database
* @param copyWithContent whether to copy the content too, otherwise only structure
+ * @return YES on success, NO on any kind of error (unspecified)
*/
- (BOOL)copyTable:(NSString *)tableName from: (NSString *)sourceDB to: (NSString *)targetDB withContent:(BOOL)copyWithContent;
+/**
+ * This method copies a bunch of tables including their data from one db to another.
+ *
+ * @param tableArray array of NSStrings with the table names in the sourceDB
+ * @param sourceDB name of the source database
+ * @param targetDB name of the target database
+ * @param copyWithContent whether to copy the content too, otherwise only structure
+ * @return YES on success, NO on any kind of error (unspecified)
+ *
+ * This method is able to copy InnoDB tables with foreign key constraints.
+ */
+- (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent;
+
@end
diff --git a/Source/SPTableCopy.m b/Source/SPTableCopy.m
index d390243c..5aa55df1 100644
--- a/Source/SPTableCopy.m
+++ b/Source/SPTableCopy.m
@@ -55,7 +55,7 @@
[createTableStatement release];
- return [connection queryErrored];
+ return ![connection queryErrored];
}
[createTableStatement release];
@@ -66,10 +66,10 @@
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent
{
// Copy the table structure
- BOOL structureCopyResult = [self copyTable:tableName from:sourceDB to:targetDB];
+ BOOL structureCopySuccess = [self copyTable:tableName from:sourceDB to:targetDB];
// Optionally copy the table data using an insert select
- if (structureCopyResult && structureCopyResult && copyWithContent) {
+ if (structureCopySuccess && copyWithContent) {
NSString *copyDataStatement = [NSString stringWithFormat:@"INSERT INTO %@.%@ SELECT * FROM %@.%@",
[targetDB backtickQuotedString],
@@ -80,12 +80,34 @@
[connection queryString:copyDataStatement];
- if ([connection queryErrored]) return NO;
-
- return YES;
+ return ![connection queryErrored];
}
- return structureCopyResult;
+ return structureCopySuccess;
+}
+
+- (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent
+{
+ BOOL success = YES;
+
+ //disable foreign key checks
+ [connection queryString:@"/*!32352 SET foreign_key_checks=0 */"];
+ if([connection queryErrored])
+ success = NO;
+
+ //copy tables
+ for(NSString *tableName in tablesArray) {
+ if(![self copyTable:tableName from:sourceDB to:targetDB withContent:copyWithContent])
+ success = NO;
+ }
+
+ //enable foreign key checks
+ [connection queryString:@"/*!32352 SET foreign_key_checks=1 */"];
+ if([connection queryErrored])
+ success = NO;
+
+ //done
+ return success;
}
- (BOOL)moveTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *)targetDB