Moved from GitHub dgraph/3841
Posted by AlexandreDaSilva:
-
What version of Dgraph are you using?
Dgraph version : v1.0.16
Commit SHA-1 : 0590ee95
Commit timestamp : 2019-07-11 11:52:54 -0700
Branch : HEAD
Go version : go1.12.5 -
Have you tried reproducing the issue with latest release?
Yes, v1.1.0-rc1, and the behavior is the same. -
What is the hardware spec (RAM, OS)?
Windows 10 Pro, version 1903
Intel Core i7-9750H
16GB of RAM
SSD 512GB -
Steps to reproduce the issue (command/config used to run Dgraph).
From a clean install of Dgraph, I create the following schema:
<Profile.age>: int .
<Profile.firstname>: string @index(hash, trigram) .
<Profile>: string @index(exact) .
I use the Profile
predicate to type my nodes.
In the same transaction, I try to create a node, then verify it exists.
const txn = client.newTxn();
const p = {
Profile: "__type",
"Profile.age": 10,
"Profile.firstname": "u1"
};
const mu = new Mutation();
mu.setSetJson(p);
await txn.mutate(mu);
const result = await txn.query(`
{
profiles(func: has(Profile)) {
uid
expand(_all_) {
uid
}
}
}
`);
const json = result.getJson();
// Log: Object {profiles: Array(0)}
// Should be: Object {profiles: Array(1)}
console.log(json);
await txn.commit();
- Expected behaviour and actual result.
The above code snippet should return one result. has()
function should work during a transaction and behave like the others functions (for example, eq
). Currently, this code snippet doesn’t work, and I get no result.
If I replace has(Profile)
with eq(Profile, "__type")
, I can find my node and I get the expected result.
If I execute the query using has(Profile)
after the transaction has been committed, I can find my node.
After some digging, I found that the last version where has()
works as I think it should during a transaction is v1.0.9. Starting from v1.0.10, the behavior is different.
#2724 was introduced in v1.0.10, it may be related.