Skip to content

Commit

Permalink
Reverting expected behavior for distinct list with null element, fixi…
Browse files Browse the repository at this point in the history
…ng core processor to match. Changing limit,skip,range tests to only check is the engine is internally consistant.
  • Loading branch information
kellrott committed Mar 24, 2020
1 parent 6a86111 commit ae96740
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
16 changes: 8 additions & 8 deletions conformance/tests/ot_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ def test_limit(O, man):
]

expected_results = [
["Character:1", "Character:10", "Character:12"],
['(Character:1)-[films]->(Film:1)', '(Character:1)-[homeworld]->(Planet:1)', '(Character:1)-[species]->(Species:1)']
list(i.gid for i in O.query().V().execute())[:3],
list(i.gid for i in O.query().E().execute())[:3]
]

for test, expected in zip(tests, expected_results):
Expand Down Expand Up @@ -394,8 +394,8 @@ def test_skip(O, man):
]

expected_results = [
['Character:13', 'Character:14', 'Character:15'],
['(Character:1)-[starships]->(Starship:12)', '(Character:10)-[films]->(Film:1)', '(Character:10)-[species]->(Species:1)']
list(i.gid for i in O.query().V().execute())[3:6],
list(i.gid for i in O.query().E().execute())[3:6]
]

for test, expected in zip(tests, expected_results):
Expand Down Expand Up @@ -433,10 +433,10 @@ def test_range(O, man):
]

expected_results = [
['Character:13', 'Character:14'],
['Starship:9', 'Vehicle:4', 'Vehicle:6', 'Vehicle:7', 'Vehicle:8'],
['(Species:3)-[people]->(Character:13)', '(Species:4)-[films]->(Film:1)', '(Species:4)-[people]->(Character:15)'],
['(Vehicle:4)-[films]->(Film:1)', '(Vehicle:6)-[films]->(Film:1)', '(Vehicle:7)-[films]->(Film:1)', '(Vehicle:8)-[films]->(Film:1)']
list(i.gid for i in O.query().V().execute())[3:5],
list(i.gid for i in O.query().V().execute())[34:],
list(i.gid for i in O.query().E().execute())[120:123],
list(i.gid for i in O.query().E().execute())[140:]
]

for test, expected in zip(tests, expected_results):
Expand Down
4 changes: 2 additions & 2 deletions conformance/tests/ot_distinct.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_distinct_multi(O, man):
if i[0] in o and o[i[0]] != i[1]:
errors.append("Non-unique pair returned: %s" % (i))
count += 1
if count != 68:
errors.append("Distinct multi %s != %s" % (count, 68))
if count != 29:
errors.append("Distinct multi %s != %s" % (count, 29))

return errors
5 changes: 4 additions & 1 deletion engine/core/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,13 +835,16 @@ func (g *Distinct) Process(ctx context.Context, man gdbi.Manager, in gdbi.InPipe
kv := man.GetTempKV()
for t := range in {
s := make([][]byte, len(g.vals))
found := true
for i, v := range g.vals {
if jsonpath.TravelerPathExists(t, v) {
s[i] = []byte(fmt.Sprintf("%#v", jsonpath.TravelerPathLookup(t, v)))
} else {
found = false
}
}
k := bytes.Join(s, []byte{0x00})
if len(k) > 0 {
if found && len(k) > 0 {
if !kv.HasKey(k) {
kv.Set(k, []byte{0x01})
out <- t
Expand Down
6 changes: 1 addition & 5 deletions mongo/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,7 @@ func (comp *Compiler) Compile(stmts []*gripql.GraphStatement) (gdbi.Pipeline, er
if namespace != jsonpath.Current {
f = fmt.Sprintf("marks.%s.%s", namespace, f)
}
// NOTE: Checking if the key did exist was on, but was then
// turned off to match behavior in the core driver
// if conformance defined as ignoring vertices with null fields when
// doing distinct, this shoul be added back in
// match[f] = bson.M{"$exists": true}
match[f] = bson.M{"$exists": true}
k := strings.Replace(f, ".", "_", -1)
keys[k] = "$" + f
}
Expand Down

0 comments on commit ae96740

Please sign in to comment.