From 59527d9acd227a9a924fbd66ed29b85ea8b65a02 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 10 Jul 2011 12:44:15 +0000 Subject: 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. --- Source/SPSQLExporter.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Source/SPSQLExporter.m') 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]]; } -- cgit v1.2.3