aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2014-03-19 19:51:00 +0100
committerMax <post@wickenrode.com>2014-03-19 19:51:00 +0100
commitf9837de31479152d8c29f06222bac3f5541b60b3 (patch)
treee84021b72921740b3b7799e7d0f7d9e8bb1ebc00
parent2645c9480332d8dde088e09a57504cdd26a541b1 (diff)
downloadsequelpro-f9837de31479152d8c29f06222bac3f5541b60b3.tar.gz
sequelpro-f9837de31479152d8c29f06222bac3f5541b60b3.tar.bz2
sequelpro-f9837de31479152d8c29f06222bac3f5541b60b3.zip
Add basic support for CURRENT_TIMESTAMP in DATETIME columns (MySQL 5.6.5)
See #1867
-rw-r--r--Source/SPSQLExporter.m2
-rw-r--r--Source/SPTableData.m2
-rw-r--r--Source/SPTableStructure.m4
-rw-r--r--Source/SPTableStructureLoading.m5
4 files changed, 7 insertions, 6 deletions
diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m
index 03958f32..649e4ac3 100644
--- a/Source/SPSQLExporter.m
+++ b/Source/SPSQLExporter.m
@@ -884,7 +884,7 @@
[fieldString appendString:@" DEFAULT NULL"];
}
}
- else if ([[column objectForKey:@"type"] isEqualToString:@"TIMESTAMP"] && [column objectForKey:@"default"] != [NSNull null] && [[[column objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) {
+ else if (([[column objectForKey:@"type"] isEqualToString:@"TIMESTAMP"] || [[column objectForKey:@"type"] isEqualToString:@"DATETIME"]) && [column objectForKey:@"default"] != [NSNull null] && [[[column objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) {
[fieldString appendString:@" DEFAULT CURRENT_TIMESTAMP"];
}
else {
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index e4945305..5158d4be 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -1343,7 +1343,7 @@
[detailParser release];
definitionPartsIndex++;
- // Special timestamp case - Whether fields are set to update the current timestamp
+ // Special timestamp/datetime case - Whether fields are set to update the current timestamp
} else if ([detailString isEqualToString:@"ON"] && (definitionPartsIndex + 2 < partsArrayLength)
&& [[NSArrayObjectAtIndex(definitionParts, definitionPartsIndex+1) uppercaseString] isEqualToString:@"UPDATE"]
&& [[NSArrayObjectAtIndex(definitionParts, definitionPartsIndex+2) uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) {
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index b2675271..807ff1ae 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -856,8 +856,8 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey";
[queryString appendString:@"\n DEFAULT NULL"];
}
}
- // Otherwise, if CURRENT_TIMESTAMP was specified for timestamps, use that
- else if ([theRowType isEqualToString:@"TIMESTAMP"] &&
+ // Otherwise, if CURRENT_TIMESTAMP was specified for timestamps/datetimes, use that
+ else if (([theRowType isEqualToString:@"TIMESTAMP"] || [theRowType isEqualToString:@"DATETIME"]) &&
[[[theRow objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"])
{
[queryString appendString:@"\n DEFAULT CURRENT_TIMESTAMP"];
diff --git a/Source/SPTableStructureLoading.m b/Source/SPTableStructureLoading.m
index 399176c2..07656155 100644
--- a/Source/SPTableStructureLoading.m
+++ b/Source/SPTableStructureLoading.m
@@ -247,8 +247,9 @@
[theField setObject:@"auto_increment" forKey:@"Extra"];
}
- // For timestamps check to see whether "on update CURRENT_TIMESTAMP" and set Extra accordingly
- else if ([type isEqualToString:@"TIMESTAMP"] && [[theField objectForKey:@"onupdatetimestamp"] integerValue]) {
+ // For timestamps/datetime check to see whether "on update CURRENT_TIMESTAMP" and set Extra accordingly
+ else if (([type isEqualToString:@"TIMESTAMP"] || [type isEqualToString:@"DATETIME"]) &&
+ [[theField objectForKey:@"onupdatetimestamp"] integerValue]) {
[theField setObject:@"on update CURRENT_TIMESTAMP" forKey:@"Extra"];
}
}