Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ String beginSql() {

public static TransactionMode from(String mode) {
try {
return valueOf(mode.toUpperCase());
return valueOf(mode.toUpperCase(java.util.Locale.ROOT));
} catch (RuntimeException e) {
throw new IllegalArgumentException("Unknown transaction mode: " + mode, e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.magnusp.libsql.jdbc;

import java.util.Locale;

/**
* Query builders for the JDBC metadata surfaces. The SQL text is the contract: tests assert
* fragments byte for byte, and the test doubles dispatch on substrings such as {@code JOIN
Expand Down Expand Up @@ -33,7 +35,7 @@ static String tables(String tableNamePattern, String[] types) {
if (i > 0) {
sql.append(",");
}
sql.append("'").append(literal(types[i].toUpperCase())).append("'");
sql.append("'").append(literal(types[i].toUpperCase(Locale.ROOT))).append("'");
}
sql.append(")");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,27 @@ void columnMetadataFoldsUnderATurkishDefaultLocale() {
.isEqualTo("NUMERIC");
}

@Test
void transactionModeFoldsUnderATurkishDefaultLocale() {
Locale.setDefault(TURKISH);

assertThat(LibsqlConnection.TransactionMode.from("immediate"))
.as("TransactionMode.from must fold with Locale.ROOT, not the default locale")
.isEqualTo(LibsqlConnection.TransactionMode.IMMEDIATE);
assertThat(LibsqlConnection.TransactionMode.from("exclusive"))
.as("TransactionMode.from must fold with Locale.ROOT, not the default locale")
.isEqualTo(LibsqlConnection.TransactionMode.EXCLUSIVE);
}

@Test
void tableTypeFilterFoldsUnderATurkishDefaultLocale() {
Locale.setDefault(TURKISH);

assertThat(MetadataSql.tables("%", new String[] {"table", "view"}))
.as("MetadataSql must fold table types with Locale.ROOT, not the default locale")
.contains("AND TABLE_TYPE IN ('TABLE','VIEW')");
}

@Test
void declaredTypeFoldsUnderATurkishDefaultLocale() {
Locale.setDefault(TURKISH);
Expand All @@ -178,7 +199,7 @@ void foreignKeyRulesFoldUnderATurkishDefaultLocale() {
Value.of("parent_id"),
Value.of("id"),
Value.of("cascade"), // update rule
Value.of("set null"), // delete rule
Value.of("restrict"), // delete rule
Value.of("CREATE TABLE child (parent_id INTEGER REFERENCES parent(id))"),
Value.of("CREATE TABLE parent (id INTEGER PRIMARY KEY)"),
Value.of("id")))),
Expand All @@ -195,7 +216,7 @@ void foreignKeyRulesFoldUnderATurkishDefaultLocale() {
.isEqualTo(DatabaseMetaData.importedKeyCascade);
assertThat(integer(imported, FOREIGN_KEY_COLUMNS, "DELETE_RULE"))
.as("ForeignKeyMetadata must fold the rule with Locale.ROOT, not the default locale")
.isEqualTo(DatabaseMetaData.importedKeySetNull);
.isEqualTo(DatabaseMetaData.importedKeyRestrict);
}

private static String typeName(StmtResult result) {
Expand Down
Loading