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

Incorrect result of function #8811

Closed
schernolyas opened this issue Mar 11, 2019 · 5 comments
Closed

Incorrect result of function #8811

schernolyas opened this issue Mar 11, 2019 · 5 comments

Comments

@schernolyas
Copy link

OrientDB Version: 3.0.17

Java Version: Java 8

OS: Ubuntu

Expected behavior

function returns collection of @Rid insteed objects

Actual behavior

function must return result objects

Steps to reproduce

I have function:
return orient.getDatabase().query("select expand(outE(?).inV()) from " + fromRID)
The function is developed by JS.
orientdb {db=test}> select expand(outE(?).inV()) from #29:0

+----+-----+------+------+---------+
|# |@Rid |@Class|title |in_Author|
+----+-----+------+------+---------+
|0 |#33:0|Book |Ivahoe|[#37:0] |
+----+-----+------+------+---------+

but function returns:
orientdb {db=test}> select findv(#29:0)

+----+------------+
|# |findv(#29:0)|
+----+------------+
|0 |[#33:0] |
+----+------------+

Content of table OFuction:
orientdb {db=test}> select from OFunction;

+----+----+---------+----------+---------+----------+---------------------------------------------------------------------------------+----------+
|# |@Rid|@Class |idempotent|name |language |code |parameters|
+----+----+---------+----------+---------+----------+---------------------------------------------------------------------------------+----------+
|0 |#6:0|OFunction| |getNumber|groovy |return 1; | |
|1 |#6:1|OFunction| |findV |javascript|return orient.getDatabase().query("select expand(outE(?).inV()) from " + fromRID)|[fromRID] |
+----+----+---------+----------+---------+----------+---------------------------------------------------------------------------------+----------+

@schernolyas
Copy link
Author

How I can get result of the query by function ?
I saw to code . Method "query" returns collection of @Rid only.

@schernolyas
Copy link
Author

@luigidellaquila
Copy link
Member

Hi @schernolyas

I think the function is working fine, the problem is the way you are using it.
The function returns a result set, the SELECT function() returns a projection of that result set, that is why you are seeing the difference.

The solution is to expand the result of the function as follows:

select expand(findv(#29:0))

I hope it helps

Thanks

Luigi

@schernolyas
Copy link
Author

Hi @luigidellaquila !

orientdb {db=test}> select findv(#29:0)

+----+------------+
|# |findv(#29:0)|
+----+------------+
|0 |[#33:0] |
+----+------------+

1 item(s) found. Query executed in 0.014 sec(s).
orientdb {db=test}> select expand(findv(#29:0))

0 item(s) found. Query executed in 0.003 sec(s).
orientdb {db=test}>

Nothing :-(
It isn't help :-(

@schernolyas
Copy link
Author

@luigidellaquila
But your idea is right:
orientdb {db=test}> select expand(#29:0)

+----+-----+------+------------+----------+
|# |@Rid |@Class|name |out_Author|
+----+-----+------+------------+----------+
|0 |#29:0|Writer|Walter Scott|[#37:0] |
+----+-----+------+------------+----------+

1 item(s) found. Query executed in 0.008 sec(s).
orientdb {db=test}>

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

No branches or pull requests

2 participants