2015-08-14 37 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]是否是一個字典或「簡單值」。如果是字典,應該像現在這樣處理,否則它應該像字段一樣處理,但是從中刪除@。

最終,在字段名稱中不使用@符號將是最簡單的解決方案。