From af045e33aae9756464e42dc51ea1f4b8cea91097 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 14 Sep 2009 23:21:07 +0000 Subject: - Fix an SQL view export error - some MySQL server versions allow NOT NULL DEFAULT NULL, but don't allow definition of tables as that - fix the export of temporary placeholder tables for those views. Thanks to Andreas Falk for report and details. --- Source/TableDump.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Source') diff --git a/Source/TableDump.m b/Source/TableDump.m index 55f81e1a..994b45bc 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -2453,8 +2453,12 @@ // Provide the field default if appropriate if ([column objectForKey:@"default"]) { + + // Some MySQL server versions show a default of NULL for NOT NULL columns - don't export those. if ([[column objectForKey:@"default"] isEqualToString:@"NULL"]) { - [fieldString appendString:@" DEFAULT NULL"]; + if ([[column objectForKey:@"null"] intValue]) + [fieldString appendString:@" DEFAULT NULL"]; + } else if ([[column objectForKey:@"type"] isEqualToString:@"TIMESTAMP"] && [[[column objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) { [fieldString appendString:@" DEFAULT CURRENT_TIMESTAMP"]; -- cgit v1.2.3