pyorient icon indicating copy to clipboard operation
pyorient copied to clipboard

Is it possible to read dynamic attributes with OGM?

Open acriptis opened this issue 7 years ago • 3 comments

I have a database with a lot of Classes. The classes are created with "weak" schema (objects of classes actually have attributes that are not defined in schema in OrientDB).

For example, I have a class UBERON which specifies id property, but the most of nodes of the class have name and definition attributes as well. These attributes are not defined in schema.

So when I do:

...
classes_from_schema = obo_graph.build_mapping(OBO_Node, OBO_Relationship, auto_plural=True)
# Initialize Schema in PyOrient
obo_graph.include(classes_from_schema)
uberon_obj = obo_graph.registry["UBERON"].objects.query(**{"@rid": "#30:740"})[0]
print(uberon_obj._props)

I got output: {'id': '0004050'} but in Orient Studio I see all attributes of the object (including those which are not defined in schema): 180131 uberon with dynamic schema Is there any way to get dynamic attributes from OGM's objects?

I know I can get them using low-level graph interface by requesting orientRecords and introspecting into their oRecordData dict, but it would be great to have access for complete attributes dictionary with OGM.

acriptis avatar Jan 31 '18 07:01 acriptis

Also interested in this feature.

PetrovskYYY avatar May 03 '18 13:05 PetrovskYYY

Hi @acriptis

So, just to clarify, does this assume some sort of check that the element with record-id #30:740 is actually an UBERON, or are you looking for a 'Query' that just maps a query 'SELECT * FROM #30:740' to an instance of obo_graph.registry["UBERON"] (without an explicit check)?

TropicalPenguin avatar May 03 '18 20:05 TropicalPenguin

@TropicalPenguin, this is not about SQL. If you use SQL directly - you have access to all fields that are defined in database any you can set any new without any problem. OGM narrows list of fields you are able to define to the ones that are defined in class schema. Even if other fields exist in database you will NOT see them and you will be unable to set any outside of schema. Sometimes it makes a problem.

PetrovskYYY avatar Oct 05 '18 07:10 PetrovskYYY