Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unify special chars in index property #1670

Merged
merged 4 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fxi 0x00 is not allowed by some backends
Change-Id: Ie682a7df5ad013808520a4f89af021a50a6086c5
  • Loading branch information
javeme committed Nov 24, 2021
commit 1e208e090451b365c43512c69dfca86d8e6aa756
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