Skip to content

Commit

Permalink
Fix Turkish/Indonesian/etc.. Locale bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbezverhni committed Sep 27, 2017
1 parent 661d20e commit 1894530
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/com/j256/ormlite/table/TableInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ public FieldType getFieldTypeByColumnName(String columnName) {
// build our alias map if we need it
Map<String, FieldType> map = new HashMap<String, FieldType>();
for (FieldType fieldType : fieldTypes) {
map.put(fieldType.getColumnName().toLowerCase(), fieldType);
map.put(lowerCaseEntityName(fieldType.getColumnName()), fieldType);
}
fieldNameMap = map;
}
FieldType fieldType = fieldNameMap.get(columnName.toLowerCase());
FieldType fieldType = fieldNameMap.get(lowerCaseEntityName(columnName));
// if column name is found, return it
if (fieldType != null) {
return fieldType;
Expand All @@ -155,6 +155,15 @@ public FieldType getFieldTypeByColumnName(String columnName) {
throw new IllegalArgumentException("Unknown column name '" + columnName + "' in table " + tableName);
}

private String lowerCaseEntityName(String columnName) {
/*
* We are forcing the ENGLISH locale because of locale capitalizaton/lowercasing issues. In a couple of languages, the
* capital version of many letters is a letter that is incompatible with many SQL libraries. For example, in
* Turkish (Locale.forLanguageTag("tr-TR")), "I".toLowerCase() returns "ı" instead of "i".
*/
return columnName.toLowerCase(Locale.ENGLISH);
}

/**
* Return the id-field associated with the object.
*/
Expand Down

0 comments on commit 1894530

Please sign in to comment.