Skip to content

Commit

Permalink
refactor: Add a test for objects that not coerceable to strings. (#561)
Browse files Browse the repository at this point in the history
Closes #401.
  • Loading branch information
michael-simons authored Mar 11, 2024
1 parent 9016cb2 commit a38f66a
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}

0 comments on commit a38f66a

Please sign in to comment.