In orientdb 2.2 - Trying to set default value of a property to a JSON string

Joshua Stillerman Source

I am using orientdb 2.2 and am trying to define a property that has a default value which is a json string.

I do not want its default value to be the object represented by the string, I want it to be the actual string. I have:

create property Person._template STRING;
alter property  Person._template default '{\"title\":[\"firstname\", \"lastname\"], \"brief\":[\"email\"], \"body\":[\"phone\",\"dbname\"], \"links\":[]}';

and when I ask the database what about this property of the schema I get back exactly what I expect:

select expand(properties) from (
  select expand(classes) from metadata:schema
  ) where name = 'Person'

{"title":["firstname", "lastname"], "brief":["email"], "body":["phone","dbname"], "links":[]}

However when I insert one of these records and retrieve its _template I get: select _template from Person

{brief=[email], links=[], title=[firstname, lastname], body=[phone, dbname]}

It is clearly treating the default value string as a directive to create some structured data. If I use the same string syntax on insert into or update queries, I get the JSON string that I expect.

So how do I set the default value for this property to be the JSON string instead of the data structure that is being produced.

Alternatively, how do I retrieve the parts of this data structure it is making.

Thanks, Josh



comments powered by Disqus