aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPServerSupport.h8
-rw-r--r--Source/SPServerSupport.m5
-rw-r--r--Source/SPTableStructureDelegate.m25
3 files changed, 27 insertions, 11 deletions
diff --git a/Source/SPServerSupport.h b/Source/SPServerSupport.h
index 4cb68726..6f6f4038 100644
--- a/Source/SPServerSupport.h
+++ b/Source/SPServerSupport.h
@@ -88,6 +88,9 @@
// Indexes
BOOL supportsIndexKeyBlockSize;
+ // Data types
+ BOOL supportsFractionalSeconds;
+
// Server versions
NSInteger serverMajorVersion;
NSInteger serverMinorVersion;
@@ -239,6 +242,11 @@
*/
@property (readonly) BOOL supportsQuotingEngineTypeInCreateSyntax;
+/**
+ * @property supportsFractionalSeconds Indicates whether the server supports fractional seconds in date/time data types.
+ */
+@property (readonly) BOOL supportsFractionalSeconds;
+
- (id)initWithMajorVersion:(NSInteger)majorVersion minor:(NSInteger)minorVersion release:(NSInteger)releaseVersion;
- (void)evaluate;
diff --git a/Source/SPServerSupport.m b/Source/SPServerSupport.m
index 78a2b287..95120494 100644
--- a/Source/SPServerSupport.m
+++ b/Source/SPServerSupport.m
@@ -73,6 +73,7 @@
@synthesize supportsTriggers;
@synthesize supportsIndexKeyBlockSize;
@synthesize supportsQuotingEngineTypeInCreateSyntax;
+@synthesize supportsFractionalSeconds;
@synthesize serverMajorVersion;
@synthesize serverMinorVersion;
@synthesize serverReleaseVersion;
@@ -192,6 +193,9 @@
// MySQL 4.0 doesn't seem to like having the ENGINE/TYPE quoted in a table's create syntax
supportsQuotingEngineTypeInCreateSyntax = [self isEqualToOrGreaterThanMajorVersion:4 minor:1 release:0];
+
+ // Fractional second support wasn't added until MySQL 5.6.4
+ supportsFractionalSeconds = [self isEqualToOrGreaterThanMajorVersion:5 minor:6 release:4];
}
/**
@@ -280,6 +284,7 @@
supportsTriggers = NO;
supportsIndexKeyBlockSize = NO;
supportsQuotingEngineTypeInCreateSyntax = NO;
+ supportsFractionalSeconds = NO;
}
/**
diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m
index c2bdb98c..ec6e984f 100644
--- a/Source/SPTableStructureDelegate.m
+++ b/Source/SPTableStructureDelegate.m
@@ -548,37 +548,37 @@
[aCell setEnabled:NO];
}
else {
- // validate cell against current field type
+ // Validate cell against current field type
+ NSString *rowType = @"";
NSDictionary *theRow = NSArrayObjectAtIndex(tableFields, rowIndex);
- NSString *theRowType = @"";
- if ((theRowType = [theRow objectForKey:@"type"])) {
- theRowType = [[theRowType stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
+ if ((rowType = [theRow objectForKey:@"type"])) {
+ rowType = [[rowType stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
}
// Only string fields allow encoding settings
if (([[aTableColumn identifier] isEqualToString:@"encoding"])) {
- [aCell setEnabled:([fieldValidation isFieldTypeString:theRowType] && [[tableDocumentInstance serverSupport] supportsPost41CharacterSetHandling])];
+ [aCell setEnabled:([fieldValidation isFieldTypeString:rowType] && [[tableDocumentInstance serverSupport] supportsPost41CharacterSetHandling])];
}
// Only string fields allow collation settings and string field is not set to BINARY since BINARY sets the collation to *_bin
else if ([[aTableColumn identifier] isEqualToString:@"collation"]) {
- [aCell setEnabled:([fieldValidation isFieldTypeString:theRowType] && [[theRow objectForKey:@"binary"] integerValue] == 0 && [[tableDocumentInstance serverSupport] supportsPost41CharacterSetHandling])];
+ [aCell setEnabled:([fieldValidation isFieldTypeString:rowType] && [[theRow objectForKey:@"binary"] integerValue] == 0 && [[tableDocumentInstance serverSupport] supportsPost41CharacterSetHandling])];
}
// Check if UNSIGNED and ZEROFILL is allowed
else if ([[aTableColumn identifier] isEqualToString:@"zerofill"] || [[aTableColumn identifier] isEqualToString:@"unsigned"]) {
- [aCell setEnabled:([fieldValidation isFieldTypeNumeric:theRowType] && ![theRowType isEqualToString:@"BIT"])];
+ [aCell setEnabled:([fieldValidation isFieldTypeNumeric:rowType] && ![rowType isEqualToString:@"BIT"])];
}
// Check if BINARY is allowed
else if ([[aTableColumn identifier] isEqualToString:@"binary"]) {
- [aCell setEnabled:([fieldValidation isFieldTypeAllowBinary:theRowType])];
+ [aCell setEnabled:([fieldValidation isFieldTypeAllowBinary:rowType])];
}
// TEXT, BLOB, and GEOMETRY fields don't allow a DEFAULT
else if ([[aTableColumn identifier] isEqualToString:@"default"]) {
- [aCell setEnabled:([theRowType hasSuffix:@"TEXT"] || [theRowType hasSuffix:@"BLOB"] || [fieldValidation isFieldTypeGeometry:theRowType]) ? NO : YES];
+ [aCell setEnabled:([rowType hasSuffix:@"TEXT"] || [rowType hasSuffix:@"BLOB"] || [fieldValidation isFieldTypeGeometry:rowType]) ? NO : YES];
}
// Check allow NULL
@@ -588,11 +588,14 @@
// TEXT, BLOB, date, and GEOMETRY fields don't allow a length
else if ([[aTableColumn identifier] isEqualToString:@"length"]) {
- [aCell setEnabled:([theRowType hasSuffix:@"TEXT"] || [theRowType hasSuffix:@"BLOB"] || ([fieldValidation isFieldTypeDate:theRowType] && ![theRowType isEqualToString:@"YEAR"]) || [fieldValidation isFieldTypeGeometry:theRowType]) ? NO : YES];
+ [aCell setEnabled:([rowType hasSuffix:@"TEXT"] ||
+ [rowType hasSuffix:@"BLOB"] ||
+ ([fieldValidation isFieldTypeDate:rowType] && ![[tableDocumentInstance serverSupport] supportsFractionalSeconds] && ![rowType isEqualToString:@"YEAR"]) ||
+ [fieldValidation isFieldTypeGeometry:rowType]) ? NO : YES];
}
else {
[aCell setEnabled:YES];
- }
+ }
}
}