2.1.1 broke calculations in sql

79 views
Skip to first unread message

alexander anguiano

unread,
Sep 11, 2015, 6:05:46 PM9/11/15
to OrientDB
I'm trying to move from 2.0.2 to 2.1.1, this query worked in 2.0.2

        select hostname, date().asLong(), $agent.lastCommunicationTime[0].asLong() , date().asLong() -  $agent.lastCommunicationTime[0].asLong(),
    $agent.version as agentVersion, $agent.lastCommunicationTime as lastCommunicationTime
    from (select expand(in("MemberOf")) from #14:1 )  Let $agent = in("Manages") where @class = 'Asset' and (date() - $agent.lastCommunicationTime[0]) > 40000
 
expect
date - $agent = 451605
1442008565000 - 1442008113395 = 451605

actual
date - $agent = date

{
    "result": [
        {
            "@type": "d",
            "@rid": "#-2:0",
            "@version": 0,
            "hostname": "JALQECG054.cddom100.lab",
            "date": 1442008565000,
            "$agent": 1442008113395,
            "date2": 1442008565000,
            "agentVersion": [
                "4.2.0.264"
            ],
            "lastCommunicationTime": [
                "2015-09-11 16:48:33"
            ],
            "@fieldTypes": "date=l,$agent=l,date2=l"
        }
    ],
    "notification": "Query executed in 0.117 sec. Returned 1 record(s)"
}

Giulia Brignoli

unread,
Sep 14, 2015, 3:11:37 AM9/14/15
to OrientDB
Hi Alexander,

can you send me your schema?

Regards,
Giulia

alexander anguiano

unread,
Sep 17, 2015, 3:28:00 PM9/17/15
to OrientDB
I sent the schema privately.

alexander anguiano

unread,
Oct 2, 2015, 10:31:30 AM10/2/15
to OrientDB
Ok, it looks like there a way to do this, you must use the eval

select hostname, date().asLong(), $agent.lastCommunicationTime[0].asLong() , eval(' date().asLong() -  $agent.lastCommunicationTime[0].asLong()'),
    $agent.version as agentVersion, $agent.lastCommunicationTime as lastCommunicationTime
    from (select expand(in("MemberOf")) from #14:1 )  Let $agent = in("Manages") where @class = 'Asset' and (date() - $agent.lastCommunicationTime[0]) > 40000


Reply all
Reply to author
Forward
0 new messages