From cae86c6943496128a61056b88a2c1c9420ce15ee Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 12 May 2013 20:57:57 +0000 Subject: Issue #1515: Add support for fractional seconds in date/time data types on server versions (>5.6.3) that support them. --- Source/SPTableStructureDelegate.m | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'Source/SPTableStructureDelegate.m') 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]; - } + } } } -- cgit v1.2.3