Skip to content

Commit

Permalink
add iden() method to storm node object (#1257)
Browse files Browse the repository at this point in the history
* add iden() method to storm node object
  • Loading branch information
invisig0th authored and vEpiphyte committed Jun 3, 2019
1 parent 1d84df1 commit f22d131
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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)

0 comments on commit f22d131

Please sign in to comment.