aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCustomQuery.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-09-15 16:44:36 +0000
committerBibiko <bibiko@eva.mpg.de>2010-09-15 16:44:36 +0000
commit82421b6cacb94aa3d9aaea785e8f333d0a0c82aa (patch)
tree60cac4eb84d15fcecf9fc83eac318380c997f217 /Source/SPCustomQuery.m
parent42b58dcdda0c82473bfed4df8211c6f0f343c6fc (diff)
downloadsequelpro-82421b6cacb94aa3d9aaea785e8f333d0a0c82aa.tar.gz
sequelpro-82421b6cacb94aa3d9aaea785e8f333d0a0c82aa.tar.bz2
sequelpro-82421b6cacb94aa3d9aaea785e8f333d0a0c82aa.zip
• added validation for BIT fields while in-cell-editing; only 1 or 0 are allowed to type in
• enabled max length and BIT field validation for CustomQuery
Diffstat (limited to 'Source/SPCustomQuery.m')
-rw-r--r--Source/SPCustomQuery.m27
1 files changed, 23 insertions, 4 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 6818dd7f..2a805da2 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -1480,6 +1480,16 @@
[dataCell setFont:tableFont];
[dataCell setLineBreakMode:NSLineBreakByTruncatingTail];
+ [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]];
+
+ // Set field length limit if field is a varchar to match varchar length
+ if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"string"]
+ || [[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"bit"]) {
+ [[dataCell formatter] setTextLimit:[[columnDefinition objectForKey:@"char_length"] integerValue]];
+ }
+
+ // Set field type for validations
+ [[dataCell formatter] setFieldType:[columnDefinition objectForKey:@"type"]];
[theCol setDataCell:dataCell];
[[theCol headerCell] setStringValue:[columnDefinition objectForKey:@"name"]];
@@ -2249,10 +2259,19 @@
NSArray *editStatus = [self fieldEditStatusForRow:rowIndex andColumn:[aTableColumn identifier]];
isFieldEditable = ([[editStatus objectAtIndex:0] integerValue] == 1) ? YES : NO;
- // Set max text length
- if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"string"]
- && [columnDefinition valueForKey:@"char_length"])
- [fieldEditor setTextMaxLength:[[columnDefinition valueForKey:@"char_length"] integerValue]];
+ NSString *fieldType = nil;
+ NSUInteger *fieldLength = 0;
+ NSString *fieldEncoding = nil;
+ // Retrieve the column defintion
+ fieldType = [columnDefinition objectForKey:@"type"];
+ if([columnDefinition objectForKey:@"char_length"])
+ fieldLength = [[columnDefinition objectForKey:@"char_length"] integerValue];
+ if([columnDefinition objectForKey:@"charset_name"] && ![[columnDefinition objectForKey:@"charset_name"] isEqualToString:@"binary"])
+ fieldEncoding = [columnDefinition objectForKey:@"charset_name"];
+
+ [fieldEditor setTextMaxLength:fieldLength];
+ [fieldEditor setFieldType:(fieldType==nil) ? @"" : fieldType];
+ [fieldEditor setFieldEncoding:(fieldEncoding==nil) ? @"" : fieldEncoding];
id originalData = [resultData cellDataAtRow:rowIndex column:[[aTableColumn identifier] integerValue]];
if ([originalData isNSNull]) originalData = [prefs objectForKey:SPNullValue];