提交 1888e49a authored 作者: nicolas-f's avatar nicolas-f

Update key on MVMAP update about #266

上级 c6584ac2
...@@ -237,6 +237,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> { ...@@ -237,6 +237,7 @@ public class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
if (p.isLeaf()) { if (p.isLeaf()) {
for (int i = 0; i < p.getKeyCount(); i++) { for (int i = 0; i < p.getKeyCount(); i++) {
if (keyType.equals(p.getKey(i), key)) { if (keyType.equals(p.getKey(i), key)) {
p.setKey(i, key);
return p.setValue(i, value); return p.setValue(i, value);
} }
} }
......
...@@ -93,6 +93,7 @@ public class TestSpatial extends TestBase { ...@@ -93,6 +93,7 @@ public class TestSpatial extends TestBase {
testNullableGeometryDelete(); testNullableGeometryDelete();
testNullableGeometryInsert(); testNullableGeometryInsert();
testNullableGeometryUpdate(); testNullableGeometryUpdate();
testIndexUpdateNullGeometry();
} }
private void testBug1() throws SQLException { private void testBug1() throws SQLException {
...@@ -1074,4 +1075,41 @@ public class TestSpatial extends TestBase { ...@@ -1074,4 +1075,41 @@ public class TestSpatial extends TestBase {
deleteDb("spatial"); deleteDb("spatial");
} }
public void testIndexUpdateNullGeometry() throws SQLException {
deleteDb("spatial");
Connection conn = getConnection(url);
Statement stat = conn.createStatement();
stat.execute("drop table if exists DUMMY_11;");
stat.execute("CREATE TABLE PUBLIC.DUMMY_11 (fid serial, GEOM GEOMETRY);");
stat.execute("CREATE SPATIAL INDEX PUBLIC_DUMMY_11_SPATIAL_INDEX on" +
" PUBLIC.DUMMY_11(GEOM);");
stat.execute("insert into PUBLIC.DUMMY_11(geom) values(null);");
stat.execute("update PUBLIC.DUMMY_11 set geom =" +
" 'POLYGON ((1 1, 5 1, 5 5, 1 5, 1 1))';");
ResultSet rs = stat.executeQuery("select fid, GEOM from DUMMY_11 " +
"where GEOM && " +
"'POLYGON" +
"((1 1,5 1,5 5,1 5,1 1))';");
try {
assertTrue(rs.next());
assertEquals("POLYGON ((1 1, 5 1, 5 5, 1 5, 1 1))", rs.getString(2));
} finally {
rs.close();
}
// Update again the geometry elsewhere
stat.execute("update PUBLIC.DUMMY_11 set geom =" +
" 'POLYGON ((10 10, 50 10, 50 50, 10 50, 10 10))';");
rs = stat.executeQuery("select fid, GEOM from DUMMY_11 " +
"where GEOM && " +
"'POLYGON ((10 10, 50 10, 50 50, 10 50, 10 10))';");
try {
assertTrue(rs.next());
assertEquals("POLYGON ((10 10, 50 10, 50 50, 10 50, 10 10))", rs.getString(2));
} finally {
rs.close();
}
conn.close();
deleteDb("spatial");
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论