Skip to content

Commit 6793329

Browse files
Fix SET command case preservation and add test coverage
- Fix case preservation bug in setConfiguration method where values were being uppercased - Add test for case-sensitive SET command values (setCommandPreservesCaseOfValues) - Add test for datetime array serialization (dateTimeArraySerialization) Addresses code review feedback from #3245 (comment) Co-authored-by: Roberto Franchini <robfrank@users.noreply.github.com>
1 parent 46a41ba commit 6793329

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,8 @@ private void setConfiguration(final String query) {
890890
// Make the parsing case-insensitive for the SET command
891891
final String upperQuery = query.toUpperCase(Locale.ENGLISH);
892892
final int setLength = "SET ".length();
893-
final String q = upperQuery.substring(setLength);
893+
// Use original query to preserve case of values
894+
final String q = query.substring(setLength);
894895

895896
// Try to split by either '=' or ' TO ' (case-insensitive)
896897
String[] parts = q.split("=");

postgresw/src/test/java/com/arcadedb/postgres/PostgresWJdbcIT.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,62 @@ void setDateStyleCaseInsensitive() throws Exception {
420420
}
421421
}
422422

423+
/**
424+
* Test for issue #1605: SET command should preserve case of values
425+
*/
426+
@Test
427+
void setCommandPreservesCaseOfValues() throws Exception {
428+
try (final Connection conn = getConnection()) {
429+
try (var st = conn.createStatement()) {
430+
// Execute SET with mixed case value
431+
st.execute("SET application_name = 'MyApp'");
432+
st.execute("SET client_encoding = 'UTF8'");
433+
434+
// The SET command should preserve the original case of values
435+
// This test verifies the fix doesn't uppercase values like 'MyApp' to 'MYAPP'
436+
// Note: We can't directly verify the stored value through JDBC,
437+
// but the test ensures no exceptions are thrown and the command is accepted
438+
}
439+
}
440+
}
441+
442+
/**
443+
* Test for issue #1605: Datetime arrays should be serialized correctly
444+
*/
445+
@Test
446+
void dateTimeArraySerialization() throws Exception {
447+
try (final Connection conn = getConnection()) {
448+
conn.setAutoCommit(false);
449+
try (var st = conn.createStatement()) {
450+
st.execute("CREATE VERTEX TYPE TestDateTimeArray IF NOT EXISTS");
451+
st.execute("CREATE PROPERTY TestDateTimeArray.dates IF NOT EXISTS LIST");
452+
453+
// Insert an array of datetime values
454+
st.execute("CREATE VERTEX TestDateTimeArray SET name = 'test1', dates = ['2024-05-19 17:05:11', '2024-05-20 18:06:12']");
455+
456+
// Query the datetime array
457+
ResultSet rs = st.executeQuery("SELECT dates FROM TestDateTimeArray WHERE name = 'test1'");
458+
459+
assertThat(rs.next()).isTrue();
460+
461+
// Verify the array is not null
462+
Array datesArray = rs.getArray("dates");
463+
assertThat(datesArray).isNotNull();
464+
465+
// Get array elements
466+
Object[] dates = (Object[]) datesArray.getArray();
467+
assertThat(dates).isNotNull();
468+
assertThat(dates).hasSize(2);
469+
470+
// Verify dates are strings in correct format (PostgreSQL JDBC driver will parse them)
471+
assertThat(dates[0]).isNotNull();
472+
assertThat(dates[1]).isNotNull();
473+
474+
rs.close();
475+
}
476+
}
477+
}
478+
423479
@Test
424480
@Disabled
425481
void waitForConnectionFromExternal() throws Exception {

0 commit comments

Comments
 (0)