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

Fix bug where removal of tag prop wouldn't update Node #1454

Merged
merged 1 commit into from Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions synapse/lib/node.py
Expand Up @@ -7,8 +7,6 @@

import synapse.lib.chop as s_chop
import synapse.lib.time as s_time
import synapse.lib.types as s_types
import synapse.lib.storm as s_storm

import synapse.lib.editatom as s_editatom

Expand Down Expand Up @@ -555,6 +553,8 @@ async def delTag(self, tag, init=False):
sops = [('prop:del', (self.buid, self.form.name, '#' + t, info)) for (t, v) in removed]
sops.extend([('tag:prop:del', (self.buid, self.form.name, tag, prop, {})) for (tag, prop) in tagprops])

[self.tagprops.pop(tp) for tp in tagprops]

# fire all the splices
splices = [self.snap.splice('tag:del', ndef=self.ndef, tag=t, valu=v) for (t, v) in removed]
await self.snap.stor(sops, splices)
Expand Down
17 changes: 11 additions & 6 deletions synapse/tests/test_cortex.py
Expand Up @@ -96,7 +96,6 @@ async def test_cortex_tagprop(self):
self.len(1, await core.nodes('test:int +#foo.bar'))
self.len(1, await core.nodes('test:int +#foo.bar:score'))
self.len(1, await core.nodes('test:int +#foo.bar:score=20'))
# self.len(1, await core.nodes('test:int +#foo.bar:score?=20'))
self.len(1, await core.nodes('test:int +#foo.bar:score<=30'))
self.len(1, await core.nodes('test:int +#foo.bar:score>=10'))
self.len(1, await core.nodes('test:int +#foo.bar:score*range=(10, 30)'))
Expand Down Expand Up @@ -131,18 +130,24 @@ async def test_cortex_tagprop(self):
self.len(1, await core.nodes('#foo.bar:score>=90'))
self.len(1, await core.nodes('#foo.bar:score*range=(90, 110)'))

# test that removing it explicitly behaves as intended
# remove the tag
await core.nodes('test:int=10 [ -#foo.bar ]')
self.len(0, await core.nodes('#foo.bar:score'))
self.len(0, await core.nodes('#foo.bar:score=100'))
self.len(1, await core.nodes('test:int=10 -#foo.bar:score'))

# add it back in to remove by whole tag...
# remove just the tagprop
await core.nodes('test:int=10 [ +#foo.bar:score=100 ]')
self.len(1, await core.nodes('#foo.bar:score=100'))
await core.nodes('test:int=10 [ -#foo.bar:score ]')
self.len(0, await core.nodes('#foo.bar:score'))
self.len(0, await core.nodes('#foo.bar:score=100'))
self.len(1, await core.nodes('test:int=10 -#foo.bar:score'))

# test that removing the tag removes all props indexes
await core.nodes('test:int=10 [ -#foo.bar ]')
# remove a higher-level tag
await core.nodes('test:int=10 [ +#foo.bar:score=100 ]')
nodes = await core.nodes('test:int=10 [ -#foo ]')
self.len(0, nodes[0].tagprops)
self.len(0, await core.nodes('#foo'))
self.len(0, await core.nodes('#foo.bar:score'))
self.len(0, await core.nodes('#foo.bar:score=100'))
self.len(1, await core.nodes('test:int=10 -#foo.bar:score'))
Expand Down