From 55d235bd55b7ef112fb495e2aebf98217078f78a Mon Sep 17 00:00:00 2001 From: Matei Chiperi Date: Thu, 28 Aug 2014 18:56:06 -0700 Subject: [PATCH] Added Gremlin tests for the Except operator. --- graph/iterator/not_iterator.go | 6 +++--- query/gremlin/gremlin_test.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/graph/iterator/not_iterator.go b/graph/iterator/not_iterator.go index 32d8957..28d6e84 100644 --- a/graph/iterator/not_iterator.go +++ b/graph/iterator/not_iterator.go @@ -146,11 +146,11 @@ func (it *Not) Type() graph.Type { return graph.Not } func (it *Not) Optimize() (graph.Iterator, bool) { // TODO - consider wrapping the primaryIt with a MaterializeIt - if optimizedPrimaryIt, optimized := it.primaryIt.Optimize(); optimized { + optimizedPrimaryIt, optimized := it.primaryIt.Optimize() + if optimized { it.primaryIt = optimizedPrimaryIt - return it, true } - return it, false + return it, optimized } func (it *Not) Stats() graph.IteratorStats { diff --git a/query/gremlin/gremlin_test.go b/query/gremlin/gremlin_test.go index 6d9f0cf..f2eec35 100644 --- a/query/gremlin/gremlin_test.go +++ b/query/gremlin/gremlin_test.go @@ -120,6 +120,20 @@ var testQueries = []struct { tag: "acd", expect: []string{"D"}, }, + { + message: "use Except to filter out a single vertex", + query: ` + g.V("A", "B").Except(g.V("A")).All() + `, + expect: []string{"B"}, + }, + { + message: "use chained Except", + query: ` + g.V("A", "B", "C").Except(g.V("B")).Except(g.V("C")).All() + `, + expect: []string{"A"}, + }, // Morphism tests. {