Fix node crash if incorrect SQL query fails.
Test added.
@@ -21,6 +21,7 @@ import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.sql.Statement;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.affinity.AffinityKey;
@@ -28,6 +29,7 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.testframework.GridTestUtils;
import org.junit.Test;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -255,6 +257,38 @@ public class JdbcThinComplexQuerySelfTest extends JdbcThinAbstractSelfTest {
assert cnt == 3;
}
+ /**
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testWrongArgumentType() throws Exception {
+ try (ResultSet rs = stmt.executeQuery("select * from \"org\".Organization where name = '2'")) {
+ assertFalse(rs.next());
+ }
+
+ // Check non-indexed field.
+ GridTestUtils.assertThrowsWithCause(() -> {
+ try (ResultSet rs = stmt.executeQuery("select * from \"org\".Organization where name = 2")) {
+ assertFalse(rs.next());
+ }
+
+ return null;
+ }, SQLException.class);
+
+ // Check indexed field.
+ try (ResultSet rs = stmt.executeQuery("select * from \"pers\".Person where name = '2'")) {
+ assertFalse(rs.next());
+ }
+
+ GridTestUtils.assertThrowsWithCause(() -> {
+ try (ResultSet rs = stmt.executeQuery("select * from \"pers\".Person where name = 2")) {
+ assertFalse(rs.next());
+ }
+
+ return null;
+ }, SQLException.class);
+ }
+
/**
* Person.
*/
@@ -264,7 +298,7 @@ public class JdbcThinComplexQuerySelfTest extends JdbcThinAbstractSelfTest {
private final int id;
/** Name. */
- @QuerySqlField(index = false)
+ @QuerySqlField(index = true)
private final String name;
/** Age. */
