From 40d83ed1c9760723a92f97c3e810a90e4fec5b11 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Fri, 1 Mar 2024 11:35:30 +0100 Subject: [PATCH] chore: Add a test that scalar properties are handled according to spec. This affects #81, but does not close it, as it cannot be tested with RapidMiner, as RapidMiner does not work with JDK17. --- .../org/neo4j/jdbc/it/cp/StatementIT.java | 31 +++++++++++++++++++ 1 file changed, 31 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 af024ffd..f8ddb33b 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 @@ -520,4 +520,35 @@ void noPropertyNamesShouldBeSpecial() throws SQLException { } } + // GH-81 + @Test + void nullPropertiesShallNotFailWhenBeAccessed() throws SQLException { + try (var connection = getConnection(); var stmt = connection.createStatement();) { + connection.setAutoCommit(false); + stmt.executeUpdate("CREATE (n:mynode {order_prop:1, aninteger: 42})"); + stmt.executeUpdate("CREATE (n:mynode {order_prop:2})"); + connection.commit(); + } + try (var connection = getConnection(); var stmt = connection.createStatement();) { + try (var result = stmt.executeQuery("MATCH (n:mynode) RETURN n ORDER BY n.order_prop ASC")) { + assertThat(result.next()).isTrue(); + assertThat(result.getObject("n", Value.class).get("aninteger").asInt()).isEqualTo(42); + assertThat(result.next()).isTrue(); + assertThat(result.getObject("n", Value.class).get("aninteger").isNull()).isTrue(); + assertThat(result.next()).isFalse(); + } + + try (var result = stmt.executeQuery("MATCH (n:mynode) RETURN n.aninteger ORDER BY n.order_prop ASC")) { + assertThat(result.next()).isTrue(); + assertThat(result.getInt(1)).isEqualTo(42); + assertThat(result.next()).isTrue(); + assertThat(result.getInt(1)).isZero(); + assertThat(result.wasNull()).isTrue(); + assertThat(result.next()).isFalse(); + } + + } + + } + }