OrientDB元数据属性

2024-06-25 23:20:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python尝试orientdb。我已经创建了几个顶点,我注意到,如果我在estudio web app上搜索它们时,在metadata部分会显示这些属性。 这很有意思,所以我去查询按我创建的元数据属性id过滤的顶点。 进行此操作时:

select from V where @id = somevalue

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


Tags: 数据fromwebidapp消息属性错误
1条回答
网友
1楼 · 发布于 2024-06-25 23:20:22

您的问题是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假定任何以“@”字符开头的记录字段后跟类/集群名称,然后是字段的dict。我想您可以发布到pyorient issue queue并建议上面的elif部分应该检查content[key]是dict还是“简单值”。如果它是一个dict,它应该像当前一样处理,否则应该像字段一样处理,但是要从中去掉@。在

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

相关问题 更多 >