Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to read dynamic attributes with OGM? #265

Open
acriptis opened this issue Jan 31, 2018 · 3 comments
Open

Is it possible to read dynamic attributes with OGM? #265

acriptis opened this issue Jan 31, 2018 · 3 comments

Comments

@acriptis
Copy link

acriptis commented Jan 31, 2018

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.

@PetrovskYYY
Copy link

Also interested in this feature.

@TropicalPenguin
Copy link
Collaborator

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)?

@PetrovskYYY
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants