Tuukka Norri avatar Tuukka Norri committed 8db3050

Regression fix
- String attributes that have a maximum length will again be created as VARCHAR.

Comments (0)

Files changed (2)

Sources/BXPGEntityImporter.m

 									error: (NSError **) outError
 {
 	BXEntityDescription *retval = [[mContext databaseObjectModel] matchingEntity: importedEntity inSchema: schemaName];
-	ExpectL ([retval isValidated]);
+	ExpectL (! retval || [retval isValidated]);
 	return retval;
 }
 

Sources/NSAttributeDescription+BXPGAdditions.m

 		[parentPredicates addObjectsFromArray: [parentAttribute validationPredicates]];
 	}
 	
-	if (! [parentPredicates count])
-		parentPredicates = nil;
-	
 	return parentPredicates;
 }
 
 	NSAttributeType attrType = [self attributeType];
 	NSInteger maxLength = NSIntegerMax;
 	if (NSStringAttributeType == attrType && NSIntegerMax != (maxLength = [self BXPGMaxLength]))
-		retval = [NSString stringWithFormat: @"varchar (%d)", maxLength];
+		retval = [NSString stringWithFormat: @"VARCHAR (%d)", maxLength];
 	else
 		retval = [[self class] BXPGNameForAttributeType: attrType];
 	return retval;
 				NSComparisonPredicate* predicate = (NSComparisonPredicate *) givenPredicate;
 				NSExpression* lhs = [predicate leftExpression];
 				NSExpression* rhs = [predicate rightExpression];
+				NSPredicateOperatorType op = [predicate predicateOperatorType];
 				NSExpression* lenghtExp = [NSExpression expressionForKeyPath: @"length"];
 				if ([lhs isEqual: lenghtExp])
 				{
-					NSExpression* lhs = CharLengthExpression ([self name]);
-					retval = [NSComparisonPredicate predicateWithLeftExpression: lhs rightExpression: rhs 
-																	   modifier: [predicate comparisonPredicateModifier] 
-																		   type: [predicate predicateOperatorType] 
-																		options: [predicate options]];
+					switch (op)
+					{
+						case NSEqualToPredicateOperatorType:
+						case NSGreaterThanPredicateOperatorType:
+						case NSGreaterThanOrEqualToPredicateOperatorType:
+						{
+							NSExpression* lhs = CharLengthExpression ([self name]);
+							retval = [NSComparisonPredicate predicateWithLeftExpression: lhs rightExpression: rhs 
+																			   modifier: [predicate comparisonPredicateModifier] 
+																				   type: op
+																				options: [predicate options]];
+							break;
+						}
+							
+						default:
+							retval = nil;
+							break;
+					}
 				}
 				else if ([rhs isEqual: lenghtExp])
 				{
-					NSExpression* rhs = CharLengthExpression ([self name]);
-					retval = [NSComparisonPredicate predicateWithLeftExpression: lhs rightExpression: rhs 
-																	   modifier: [predicate comparisonPredicateModifier] 
-																		   type: [predicate predicateOperatorType] 
-																		options: [predicate options]];
+					switch (op)
+					{
+						case NSEqualToPredicateOperatorType:
+						case NSLessThanPredicateOperatorType:
+						case NSLessThanOrEqualToPredicateOperatorType:
+						{
+							NSExpression* rhs = CharLengthExpression ([self name]);
+							retval = [NSComparisonPredicate predicateWithLeftExpression: lhs rightExpression: rhs 
+																			   modifier: [predicate comparisonPredicateModifier] 
+																				   type: op
+																				options: [predicate options]];
+							break;
+						}
+							
+						default:
+							retval = nil;
+							break;
+					}
 				}
 				else
 				{
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.