Closed rosenbrockc closed 7 years ago
As a follow-up, if I execute:
loop.run_until_complete(g.V(32952).properties("restaurant.locations").valueMap(True).toList())
in python, it correctly returns the list of dictionaries:
[{'address.city': 'Murray',
'address.street': '456 Ruby Ave.',
'address.uuid': {'@type': 'g:UUID',
'@value': '12345678-1234-5678-1234-567812345679'},
'address.zip': 84632,
'id': {'@type': 'janusgraph:RelationIdentifier',
'@value': {'@class': 'java.util.HashMap', 'value': 'oif-pfc-lc5'}},
'key': 'restaurant.locations',
'value': 'murray'},
{'address.city': 'Provo',
'address.street': '123 Thai St.',
'address.uuid': {'@type': 'g:UUID',
'@value': '12345678-1234-5678-1234-567812345678'},
'address.zip': 84606,
'id': {'@type': 'janusgraph:RelationIdentifier',
'@value': {'@class': 'java.util.HashMap', 'value': 'pav-pfc-lc5'}},
'key': 'restaurant.locations',
'value': 'provo'}]
I do have an appropriate get_hashable_id
defined for the id
properties.
Rats! This is what actually fixes the mapping problem:
if okey in element.__mapping__.db_properties:
key = element.__mapping__.db_properties[okey][0]
else:
key = okey
need to first check that the mapping exists. Special attributes (like id
) aren't in there...
Hi Conrad. I wan't to look into this a bit more. I just moved and am currently without computer. I will be getting set up later today. I will get to this issue sometime tomorrow afternoon.
How about something like:
key, _ = element.__mapping__.db_properties.get(key, key)
As far as the specific traversal failure, could you post a minimal example that reproduces the error?
Lol that will fail, but you get the idea, maybe:
if key in element.__mapping__.db_properties:
key, _ = element.__mapping__.db_properties[key]
I can submit a PR for this. The traversal failure was due to the case where key was not in the db_properties
dictionary. Adding the check made that problem go away. The traversals fire correctly now and get the valueMap
back. However, there may still be a problem with updating the vertex property. I'll update with more details on Friday.
Ok. If the PR isn't coming until Friday I may go ahead and make these changes myself. I plan on releasing a new Goblin today.
I am excited for the new release. Unfortunately I am on campus today and my other laptop is the one that I do the development with goblin on. The PR for #75 would also only come on Friday; it's a quick fix as well, so you may want to do that too.
No worries. I will make the fixes. Thanks a lot for reporting.
Suppose I have a vertex type
Restaurant
:This correctly get all of the regular properties. However, I have a subclass of
VertexProperty
calledAddress
. It correctly grabs the set of locations:but the individual properties of each
Address
are allNone
:I traced the problem to https://github.com/davebshow/goblin/blob/master/goblin/session.py#L223.
Because I have
db_name
mappings, the key in theprops
dictionary are the db_name instead of the property name. So the__properties__.get
returnsNone
and the secondvalueMap
request never fires.When I add:
then it works and the extra traversal is triggered. Mind, I am using the official 2.0 release on PyPI, so my version actually looks like:
and the message sent to gremlin server is:
Unfortunately, the actual query doesn't execute properly and I am at a loss as to the problem. In python I get:
But, when I execute the following in the gremlin console:
it works. Any ideas for the error? I am happy to submit a PR for the mapping issue, though you may have a better way to handle it.