Skip to content

Commit fe4814c

Browse files
authored
CBL-7610 : query collations should default to system locale instead of null (#444)
1 parent 51dbafc commit fe4814c

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

common/main/java/com/couchbase/lite/Collation.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ protected Collation(boolean isUnicode, @Nullable String locale) {
124124

125125
@NonNull
126126
protected Collation setLocale(@Nullable String locale) {
127-
this.locale = locale;
127+
// For Unicode collations, default to system locale when null is passed
128+
if (isUnicode && locale == null) {
129+
this.locale = System.getProperty("user.language");
130+
} else {
131+
this.locale = locale;
132+
}
128133
return this;
129134
}
130135

common/test/java/com/couchbase/lite/QueryTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,19 +1944,19 @@ public void testGenerateJSONCollation() {
19441944
expected.add(json2);
19451945
Map<String, Object> json3 = new HashMap<>();
19461946
json3.put("UNICODE", true);
1947-
json3.put("LOCALE", null);
1947+
json3.put("LOCALE", System.getProperty("user.language"));
19481948
json3.put("CASE", true);
19491949
json3.put("DIAC", true);
19501950
expected.add(json3);
19511951
Map<String, Object> json4 = new HashMap<>();
19521952
json4.put("UNICODE", true);
1953-
json4.put("LOCALE", null);
1953+
json4.put("LOCALE", System.getProperty("user.language"));
19541954
json4.put("CASE", false);
19551955
json4.put("DIAC", true);
19561956
expected.add(json4);
19571957
Map<String, Object> json5 = new HashMap<>();
19581958
json5.put("UNICODE", true);
1959-
json5.put("LOCALE", null);
1959+
json5.put("LOCALE", System.getProperty("user.language"));
19601960
json5.put("CASE", false);
19611961
json5.put("DIAC", false);
19621962
expected.add(json5);

0 commit comments

Comments
 (0)