From a38f66ad60fb38f705f6be178e14d8074493ee1c Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Mon, 11 Mar 2024 10:58:14 +0100 Subject: [PATCH] refactor: Add a test for objects that not coerceable to strings. (#561) Closes #401. --- .../java/org/neo4j/jdbc/it/cp/StatementIT.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/neo4j-jdbc-it/neo4j-jdbc-it-cp/src/test/java/org/neo4j/jdbc/it/cp/StatementIT.java b/neo4j-jdbc-it/neo4j-jdbc-it-cp/src/test/java/org/neo4j/jdbc/it/cp/StatementIT.java index d97b3db46..479a2c14a 100644 --- a/neo4j-jdbc-it/neo4j-jdbc-it-cp/src/test/java/org/neo4j/jdbc/it/cp/StatementIT.java +++ b/neo4j-jdbc-it/neo4j-jdbc-it-cp/src/test/java/org/neo4j/jdbc/it/cp/StatementIT.java @@ -416,4 +416,21 @@ void getObjectMustReturnTheSmallestTypePossibleForInteger() throws SQLException } } + // GH-401 + @Test + void noSurpriseGetString() throws SQLException { + try (var connection = getConnection(); + var stmt = connection.createStatement(); + var result = stmt.executeQuery("RETURN {a: '1', b: '2'} AS m, [1,2,3] AS l")) { + + assertThat(result.next()).isTrue(); + assertThatExceptionOfType(SQLException.class).isThrownBy(() -> result.getString("m")) + .withMessage("MAP value can not be mapped to String"); + assertThat(result.getObject("m")).isInstanceOf(Map.class); + assertThatExceptionOfType(SQLException.class).isThrownBy(() -> result.getString("l")) + .withMessage("LIST OF ANY? value can not be mapped to String"); + assertThat(result.getObject("l")).isInstanceOf(List.class); + } + } + }