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

add iden() method to storm node object #1257

Merged
merged 2 commits into from
Jun 3, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Synapse Changelog
*****************

v0.1.10 - TBD
===================

Features and Enhancements
-------------------------

- Add ``$node.iden()`` method in Storm to expose the iden of a node. (`#1257 <https://github.com/vertexproject/synapse/pull/1257>`_)


v0.1.9 - 2019-05-31
===================

Expand Down
4 changes: 4 additions & 0 deletions synapse/lib/stormtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def __init__(self, node, path=None):
'ndef': self._methNodeNdef,
'tags': self._methNodeTags,
'repr': self._methNodeRepr,
'iden': self._methNodeIden,
'value': self._methNodeValue,
})

Expand All @@ -271,6 +272,9 @@ async def _methNodeNdef(self):
async def _methNodeRepr(self, name=None):
return self.valu.repr(name=name)

async def _methNodeIden(self):
return self.valu.iden()

# These will go away once we have value objects in storm runtime
def toprim(valu, path=None):

Expand Down
7 changes: 7 additions & 0 deletions synapse/tests/test_lib_stormtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,10 @@ async def test_storm_csv(self):
self.eq(csv_rows[1],
('csv:row', {'row': ['test:str', '9876', '3001/01/01 00:00:00.000'],
'table': 'mytable'}))

async def test_storm_node_iden(self):
async with self.getTestCore() as core:
nodes = await core.nodes('[ test:int=10 test:str=$node.iden() ] +test:str')
iden = s_common.ehex(s_common.buid(('test:int', 10)))
self.eq(nodes[0].ndef, ('test:str', iden))
self.len(1, nodes)