2015-08-14 35 views
0

我想用python orientdb。我创建了几个顶点,并且我注意到如果我用@预先给它们的属性名称,当我在estudio web应用程序上搜索它们时,这些属性将显示在元数据部分中。 多数民众赞成在有趣的,所以我去,并试图查询顶点过滤元数据属性ID,我创建。 当这样做时:OrientDB元数据属性

select from V where @id = somevalue 

我得到一个巨大的错误消息。我无法找到查询这些自定义元数据属性的方法。

任何意见/建议?

回答

0

你的问题是与python/pyorient(我假设你正在使用pyorient根据您的其他问题)。

Pyorient尝试将数据库字段映射到对象属性,但python文档说the valid characters for identifiers are the same as in Python 2.x: the uppercase and lowercase letters A through Z, the underscore _ and, except for the first character, the digits 0 through 9.(source)。因此,您不能使用'@'作为字段名称,并期望pyorient正常工作。


我就去,在pyorient源代码快速浏览一下,和原来的问题比上述更大...... pyorient/types.py

elif key[0:1] == '@': 
    # special case dict 
    # { '@my_class': { 'accommodation': 'hotel' } } 
    self.__o_class = key[1:] 
    for _key, _value in content[key].items(): 
     self.__o_storage[_key] = _value 

所以pyorient假定开始任何记录字段'@'字符后面是类/集群名称,然后是字段的字典。我想你可以发布到pyorient issue queue,并建议上述elif部分应该检查content[key]是否是一个字典或“简单值”。如果是字典,应该像现在这样处理,否则它应该像字段一样处理,但是从中删除@。

最终,在字段名称中不使用@符号将是最简单的解决方案。