diff options
author | stuconnolly <stuart02@gmail.com> | 2011-07-10 12:44:15 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2011-07-10 12:44:15 +0000 |
commit | 59527d9acd227a9a924fbd66ed29b85ea8b65a02 (patch) | |
tree | dca62602c88706a4d64ba6d1720a744cb269dd9c /Source | |
parent | 4b071f5866460dbff1bce10a297f3b017dfea26b (diff) | |
download | sequelpro-59527d9acd227a9a924fbd66ed29b85ea8b65a02.tar.gz sequelpro-59527d9acd227a9a924fbd66ed29b85ea8b65a02.tar.bz2 sequelpro-59527d9acd227a9a924fbd66ed29b85ea8b65a02.zip |
Add the option to the SQL export view as to whether or not the AUTO_INCREMENT value on a table's structure is included. Defaults to not included. Implements issue #1064.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPExportController.h | 1 | ||||
-rw-r--r-- | Source/SPExportController.m | 2 | ||||
-rw-r--r-- | Source/SPExportFileUtilities.m | 11 | ||||
-rw-r--r-- | Source/SPExportInitializer.m | 1 | ||||
-rw-r--r-- | Source/SPSQLExporter.h | 6 | ||||
-rw-r--r-- | Source/SPSQLExporter.m | 9 |
6 files changed, 23 insertions, 7 deletions
diff --git a/Source/SPExportController.h b/Source/SPExportController.h index 0130d508..00f0ac62 100644 --- a/Source/SPExportController.h +++ b/Source/SPExportController.h @@ -92,6 +92,7 @@ IBOutlet NSButton *exportSQLBLOBFieldsAsHexCheck; IBOutlet NSTextField *exportSQLInsertNValueTextField; IBOutlet NSPopUpButton *exportSQLInsertDividerPopUpButton; + IBOutlet NSButton *exportSQLIncludeAutoIncrementValueButton; // Excel IBOutlet NSMatrix *exportExcelSheetOrFilePerTableMatrix; diff --git a/Source/SPExportController.m b/Source/SPExportController.m index b22d2c32..54be5b91 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -582,6 +582,8 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; */ - (IBAction)toggleSQLIncludeStructure:(id)sender { + [exportSQLIncludeAutoIncrementValueButton setEnabled:[sender state]]; + [[exportTableList tableColumnWithIdentifier:SPTableViewStructureColumnID] setHidden:(![sender state])]; [self _toggleExportButtonOnBackgroundThread]; diff --git a/Source/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m index b23d0b78..f3ae56e9 100644 --- a/Source/SPExportFileUtilities.m +++ b/Source/SPExportFileUtilities.m @@ -35,10 +35,13 @@ typedef enum SPExportErrorCancelExport = 0, SPExportErrorReplaceFiles = 1, SPExportErrorSkipErrorFiles = 2 -} SPExportErrorChoice; +} +SPExportErrorChoice; @interface SPExportController (SPExportFileUtilitiesPrivateAPI) - - (void)_reopenExportSheet; + +- (void)_reopenExportSheet; + @end @implementation SPExportController (SPExportFileUtilities) @@ -302,10 +305,6 @@ typedef enum } } -@end - -@implementation SPExportController (SPExportFileUtilitiesPrivateAPI) - /** * Re-open the export sheet without resetting the interface - for use on error. */ diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index f9d23b63..df615495 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -275,6 +275,7 @@ [sqlExporter setSqlOutputIncludeUTF8BOM:[exportUseUTF8BOMButton state]]; [sqlExporter setSqlOutputEncodeBLOBasHex:[exportSQLBLOBFieldsAsHexCheck state]]; [sqlExporter setSqlOutputIncludeErrors:[exportSQLIncludeErrorsCheck state]]; + [sqlExporter setSqlOutputIncludeAutoIncrement:([exportSQLIncludeStructureCheck state] && [exportSQLIncludeAutoIncrementValueButton state])]; [sqlExporter setSqlInsertAfterNValue:[exportSQLInsertNValueTextField integerValue]]; [sqlExporter setSqlInsertDivider:[exportSQLInsertDividerPopUpButton indexOfSelectedItem]]; diff --git a/Source/SPSQLExporter.h b/Source/SPSQLExporter.h index 559cdc9e..b5621bd1 100644 --- a/Source/SPSQLExporter.h +++ b/Source/SPSQLExporter.h @@ -50,6 +50,7 @@ BOOL sqlOutputIncludeUTF8BOM; BOOL sqlOutputEncodeBLOBasHex; BOOL sqlOutputIncludeErrors; + BOOL sqlOutputIncludeAutoIncrement; SPSQLExportInsertDivider sqlInsertDivider; @@ -110,6 +111,11 @@ @property(readwrite, assign) BOOL sqlOutputIncludeErrors; /** + * @property sqlOutputIncludeAutoIncrement Include auto increment in structure definition + */ +@property(readwrite, assign) BOOL sqlOutputIncludeAutoIncrement; + +/** * @property sqlCurrentTableExportIndex Number of tables processed by exporter */ @property(readwrite, assign) NSUInteger sqlCurrentTableExportIndex; diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m index 4c7903fc..66411932 100644 --- a/Source/SPSQLExporter.m +++ b/Source/SPSQLExporter.m @@ -31,8 +31,9 @@ #import "SPExportUtilities.h" #import "SPExportFile.h" #import "SPTableData.h" +#import "RegexKitLite.h" -@interface SPSQLExporter (PrivateAPI) +@interface SPSQLExporter () - (NSString *)_createViewPlaceholderSyntaxForView:(NSString *)viewName; @@ -50,6 +51,7 @@ @synthesize sqlOutputIncludeUTF8BOM; @synthesize sqlOutputEncodeBLOBasHex; @synthesize sqlOutputIncludeErrors; +@synthesize sqlOutputIncludeAutoIncrement; @synthesize sqlCurrentTableExportIndex; @synthesize sqlInsertAfterNValue; @synthesize sqlInsertDivider; @@ -263,6 +265,11 @@ createTableSyntax = [[[NSString alloc] initWithData:createTableSyntax encoding:[self exportOutputEncoding]] autorelease]; } + // If necessary strip out the AUTO_INCREMENT from the table structure definition + if (![self sqlOutputIncludeAutoIncrement]) { + createTableSyntax = [createTableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"AUTO_INCREMENT=[0-9]+ "] withString:@""]; + } + [[self exportOutputFile] writeData:[createTableSyntax dataUsingEncoding:NSUTF8StringEncoding]]; [[self exportOutputFile] writeData:[[NSString stringWithString:@";\n\n"] dataUsingEncoding:NSUTF8StringEncoding]]; } |