From a86bed3db5f1f5528b9ce38052373286719c2313 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 18 Sep 2014 22:43:40 +0200 Subject: Disable ID generation during duplicate database Should fix #1978 --- Source/SPTableCopy.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/SPTableCopy.m b/Source/SPTableCopy.m index bc2474ba..cd3fc42e 100644 --- a/Source/SPTableCopy.m +++ b/Source/SPTableCopy.m @@ -98,6 +98,13 @@ success = NO; } + // Disable auto-id creation for '0' values + [connection queryString:@"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */"]; + + if([connection queryErrored]) { + success = NO; + } + for (NSString *tableName in tablesArray) { if (![self copyTable:tableName from:sourceDB to:targetDB withContent:copyWithContent]) { @@ -112,6 +119,13 @@ success = NO; } + // re-enable id creation + [connection queryString:@"/*!40101 SET SQL_MODE=@OLD_SQL_MODE */"]; + + if ([connection queryErrored]) { + success = NO; + } + return success; } -- cgit v1.2.3