Skip to content

Commit 69f2c50

Browse files
committed
Fix ddl and dml
Tarantol connector do not send any `metadata` and `rows` in case of SQL ddl and dml. Before this patch absence of those attributes lead to a NullPointerException. Closes #39
1 parent d0b57fe commit 69f2c50

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/org/tarantool/JDBCBridge.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ protected JDBCBridge(TarantoolConnection connection) {
2222

2323
protected JDBCBridge(List<TarantoolBase.SQLMetaData> sqlMetadata, List<List<Object>> rows) {
2424
this.sqlMetadata = sqlMetadata;
25-
this.rows = rows;
25+
if (rows == null) {
26+
this.rows = new ArrayList<List<Object>>(0);
27+
} else {
28+
this.rows = rows;
29+
}
2630
columnsByName = new LinkedHashMap<String, Integer>((int) Math.ceil(sqlMetadata.size() / 0.75), 0.75f);
2731
for (int i = 0; i < sqlMetadata.size(); i++) {
2832
columnsByName.put(sqlMetadata.get(i).getName(), i + 1);

src/main/java/org/tarantool/TarantoolBase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ public String toString() {
161161

162162
protected List<SQLMetaData> getSQLMetadata() {
163163
List<Map<Integer, Object>> meta = (List<Map<Integer, Object>>) body.get(Key.SQL_METADATA.getId());
164+
if (meta == null){
165+
return new ArrayList<SQLMetaData>(0);
166+
}
164167
List<SQLMetaData> values = new ArrayList<SQLMetaData>(meta.size());
165168
for(Map<Integer,Object> c:meta ) {
166169
values.add(new SQLMetaData((String) c.get(Key.SQL_FIELD_NAME.getId())));

0 commit comments

Comments
 (0)