Permalink
Browse files

Disable ID generation during duplicate database

Should fix #1978
  • Loading branch information...
dmoagx committed Sep 18, 2014
1 parent d1425fb commit a86bed3db5f1f5528b9ce38052373286719c2313
Showing with 14 additions and 0 deletions.
  1. +14 −0 Source/SPTableCopy.m
@@ -98,6 +98,13 @@ - (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString
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 @@ - (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString
success = NO;
}
// re-enable id creation
[connection queryString:@"/*!40101 SET SQL_MODE=@OLD_SQL_MODE */"];
if ([connection queryErrored]) {
success = NO;
}
return success;
}

0 comments on commit a86bed3

Please sign in to comment.