is the @fieldTypes field supported for the embedded document?

183 views
Skip to first unread message

Claudio

unread,
Feb 3, 2013, 9:49:42 AM2/3/13
to orient-...@googlegroups.com
Hi,
is it possible to specify the type of a field in an embedded document using the @fieldTypes field?
I tried this:

insert into myClass (myDate) values ({"date":"2013-01-01","@fieldTypes":"date=d"})

Now to check that internally the date field was a Date, I tried the following update:
update myClass  increment myDate.date = 1

I was expecting a java.util.Date CastException, but I had:
Error: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: OSQLQuery [text=select from MYCLASS]
Error: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number

It seems that internally the date field is a String not a Date.

Thanks

Luca Garulli

unread,
Feb 4, 2013, 6:26:47 AM2/4/13
to orient-database
Hi Claudio,
the trick you used with @fieldTypes is supposed to work but you're inserting an entire document as "myDate" attribute. Try this:

insert into myClass (myDate) values ( date("2013-01-01 00:00:00") )

Lvc@



--
 
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Claudio Tesoriero

unread,
Feb 4, 2013, 7:09:08 AM2/4/13
to orient-...@googlegroups.com
Hi Luca,
yes this was my intention: I would to create an embedded document and I would to create a field inside it as a date field.
Let's say that the my example could be more clear. What if I try something like this:

insert into myClass (name,meta) values ("claudio",{"country":"italy", "date":"2013-01-01","@fieldTypes":"date=d"})

Thanks

2013/2/4 Luca Garulli <l.ga...@gmail.com>



--
Sent from my Commodore 64

ry...@luminusnetworks.com

unread,
Jul 31, 2015, 4:56:24 PM7/31/15
to OrientDB, giast...@gmail.com
Was this questioned ever answered.../

Luca Garulli

unread,
Aug 2, 2015, 2:44:16 PM8/2/15
to OrientDB, giast...@gmail.com
Hi,
The right type for date is "a", not "d" (double). Look at: http://orientdb.com/docs/last/OrientDB-REST.html

However I created a test case like yours and didn't work. Now it's fixed in "develop" branch and will be part of "2.1 GA" next week.

Best Regards,

Luca Garulli
Founder & CEO


For more options, visit https://groups.google.com/d/optout.

ry...@luminusnetworks.com

unread,
Aug 3, 2015, 10:29:15 AM8/3/15
to OrientDB
For anyone else who stumbles upon this, they way I was ultimately able to get @fieldTypes to work (in 2.0.12) was to include the metadata "@type":"d" in each nested embedded dictionary.
I found the clue here: https://groups.google.com/forum/#!msg/orient-database/P3LqMHW7hdY/LIreE1UxddQJ
So in this case, the following would work:
insert into myClass (name,meta) values ("claudio",{"country":"italy", "date":"2013-01-01","@fieldTypes":"date=d", "@type":"d"})

Ryan Gaffney

unread,
Aug 3, 2015, 10:37:44 AM8/3/15
to orient-...@googlegroups.com
(but with correct type for date...):
insert into myClass (name,meta) values ("claudio",{"country":"italy", "date":"2013-01-01","@fieldTypes":"date=a", "@type":"d"})


--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/JD7ZwZtE6C0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages