U4-4195 - 7.0.X PropertyValueEditor.GetDatabaseType FormatException on different regional settings

Created by Erhan CAKIRMAN 07 Feb 2014, 10:12:22 Updated by Sebastiaan Janssen 24 Feb 2014, 11:13:42

GetDatabaseType function in Umbraco.Core.PropertyEditors.PropertyValueEditor use ToUpper and checks upper cased strings within a switch-case, in some cases when using different regional settings like Turkish that leads to a FormatException.

"string" ToUpper when English Locale = "STRING" "string" ToUpper when Turkish Locale = "STRÄ°NG"

public DataTypeDatabaseType GetDatabaseType() { switch (ValueType.ToUpper()) { case "INT": case "INTEGER": return DataTypeDatabaseType.Integer; case "STRING": return DataTypeDatabaseType.Nvarchar; case "TEXT": case "JSON": case "XML": return DataTypeDatabaseType.Ntext; case "DATETIME": case "DATE": case "TIME": return DataTypeDatabaseType.Date; default: throw new FormatException("The ValueType does not match a known value type"); } }


Sebastiaan Janssen 10 Feb 2014, 08:59:42

We have a InvariantEquals extension for this. Easy fix.

Sebastiaan Janssen 24 Feb 2014, 11:13:40

Fixed in rev d02b230f7139fec70b4c6fa783cf9f6fe0255083

Priority: Minor

Type: Bug

State: Fixed


Difficulty: Very Easy


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.0.1, 7.0.2, 7.0.3

Due in version: 7.1.0


Story Points: