Skip to content

Commit

Permalink
fxi 0x00 is not allowed by some backends
Browse files Browse the repository at this point in the history
Change-Id: Ie682a7df5ad013808520a4f89af021a50a6086c5
  • Loading branch information
javeme committed Nov 24, 2021
1 parent f982d8c commit 1e208e0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5647,10 +5647,6 @@ public void testAddEdgePropertyWithSpecialValueForSecondaryIndex() {
graph.tx().commit();

long current = System.currentTimeMillis();
louise.addEdge("strike", sean, "id", 0,
"timestamp", current, "place", "park",
"tool", "a\u0000", "reason", "jeer",
"arrested", false);
louise.addEdge("strike", sean, "id", 1,
"timestamp", current, "place", "park",
"tool", "b\u0001", "reason", "jeer",
Expand All @@ -5666,9 +5662,6 @@ public void testAddEdgePropertyWithSpecialValueForSecondaryIndex() {
graph.tx().commit();

List<Edge> edges;
edges = graph.traversal().E().has("tool", "a\u0000").toList();
Assert.assertEquals(1, edges.size());
Assert.assertEquals(0, edges.get(0).value("id"));

edges = graph.traversal().E().has("tool", "b\u0001").toList();
Assert.assertEquals(1, edges.size());
Expand All @@ -5681,6 +5674,31 @@ public void testAddEdgePropertyWithSpecialValueForSecondaryIndex() {
edges = graph.traversal().E().has("tool", "d\u0003").toList();
Assert.assertEquals(1, edges.size());
Assert.assertEquals(3, edges.get(0).value("id"));

String backend = graph.backend();
Set<String> nonZeroBackends = ImmutableSet.of("postgresql",
"rocksdb", "hbase");
if (nonZeroBackends.contains(backend)) {
Assert.assertThrows(Exception.class, () -> {
louise.addEdge("strike", sean, "id", 4,
"timestamp", current, "place", "park",
"tool", "a\u0000", "reason", "jeer",
"arrested", false);
graph.tx().commit();
}, e -> {
Assert.assertContains("0x00", e.getMessage());
});
} else {
louise.addEdge("strike", sean, "id", 0,
"timestamp", current, "place", "park",
"tool", "a\u0000", "reason", "jeer",
"arrested", false);
graph.tx().commit();

edges = graph.traversal().E().has("tool", "a\u0000").toList();
Assert.assertEquals(1, edges.size());
Assert.assertEquals(0, edges.get(0).value("id"));
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5993,8 +5993,6 @@ public void testAddVertexPropertyWithSpecialValueForSecondaryIndex() {
HugeGraph graph = graph();
initPersonIndex(true);

graph.addVertex(T.label, "person", "name", "0",
"city", "a\u0000", "age", 0);
graph.addVertex(T.label, "person", "name", "1",
"city", "b\u0001", "age", 1);
graph.addVertex(T.label, "person", "name", "2",
Expand All @@ -6004,9 +6002,6 @@ public void testAddVertexPropertyWithSpecialValueForSecondaryIndex() {
graph.tx().commit();

List<Vertex> vertices;
vertices = graph.traversal().V().has("city", "a\u0000").toList();
Assert.assertEquals(1, vertices.size());
Assert.assertEquals("0", vertices.get(0).value("name"));

vertices = graph.traversal().V().has("city", "b\u0001").toList();
Assert.assertEquals(1, vertices.size());
Expand All @@ -6019,6 +6014,27 @@ public void testAddVertexPropertyWithSpecialValueForSecondaryIndex() {
vertices = graph.traversal().V().has("city", "d\u0003").toList();
Assert.assertEquals(1, vertices.size());
Assert.assertEquals("3", vertices.get(0).value("name"));

String backend = graph.backend();
Set<String> nonZeroBackends = ImmutableSet.of("postgresql",
"rocksdb", "hbase");
if (nonZeroBackends.contains(backend)) {
Assert.assertThrows(Exception.class, () -> {
graph.addVertex(T.label, "person", "name", "0",
"city", "a\u0000", "age", 0);
graph.tx().commit();
}, e -> {
Assert.assertContains("0x00", e.getMessage());
});
} else {
graph.addVertex(T.label, "person", "name", "0",
"city", "a\u0000", "age", 0);
graph.tx().commit();

vertices = graph.traversal().V().has("city", "a\u0000").toList();
Assert.assertEquals(1, vertices.size());
Assert.assertEquals("0", vertices.get(0).value("name"));
}
}

@Test
Expand Down

0 comments on commit 1e208e0

Please sign in to comment.