-
Notifications
You must be signed in to change notification settings - Fork 871
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
JDK1.8 json format #3051
Comments
this affects every response from Javascript functions. - they are always wrapped in a 'value' object. It would be better to return the same value as with 1.7 - or else wrap the response in an ODocument using fromJSON. |
Any more thoughts on this. Currently the response from javascript functions is deeply inconsistent and unwelidly. Can we try to stick to something like.. |
this issue comes from this #2388 |
I fixed this, now the behavior is consistent between java7 and java8. |
How about arrays? Are these returned as per query resu |
@luigidellaquila why differentiate? either always envelope or never envelope but alternating between the two makes things really painful for consumers. |
Hi Charles, let's talk about this, I don't like current implementation either. My function: result: {"result": 1} function: result: {"result": "foo"} function: result: {"result": {"a":1, "b":3}} function: result: {"result": [1, 2, 3]} function: result: [ IMHO it's the most consistent way to manage function results. The real problem is that this is completely different from current I'd like to have a feedback from as many users as possible to take a final Thanks Luigi 2014-11-26 17:36 GMT+01:00 Charles Pick notifications@github.com:
|
@luigidellaquila think your last example should also be enveloped, e.g. {
"result": [
{
"@type": "d",
"@rid": "#5:0",
"@version": 2,
"@class": "OUser",
"name": "admin",
"password": "...",
"status": "ACTIVE",
"roles": [
"#4:0"
],
"@fieldTypes": "roles=n"
},
{
"@type": "d",
"@rid": "#5:1",
"@version": 1,
"@class": "OUser",
"name": "reader",
"password":
"{SHA-256}3D0941964AA3EBDCB00CCEF58B1BB399F9F898465E9886D5AEC7F31090A0FB30",
"status": "ACTIVE",
"roles": [
"#4:1"
],
"@fieldTypes": "roles=n"
}
]
} Agree it might break but can be linked to the version of the binary protocol being used? |
@phpnode you are right, just missed a cut'n'paste from Studio (it doesn't show the envelope in the function result...) |
about binary compatibility, I think we cannot rely on binary protocol because it's not involved, here we are using HTTP/REST interface and it doesn't send info about protocol version. |
Luigi. I like your proposal. Less is more as It should be easy enough to modify results to cobform to the old style. |
The argument for selectively wrapping the resukts is that we can ensure the response should always include a results property which is an array of objects. This is quite helpfull |
@mattaylor not sure I understand your last point, could you explain a bit more please? @luigidellaquila I've said this before in #2273 and #2243 but there are some fundamental problems with the REST/JSON api anyway, it would be really good to be able to fix these problems by adopting a new format (could be opt in). |
My point is that it is helpfull for clients of the api to know that function calls should always return a consitent data schema. Ie a results array of objects. If the 'results' property of the response object is sometimes a scalar, sometimes an array and sometimes in object then any tooling around the api becomes much harder inc validators, sdk generators, docs, etc.. |
@mattaylor isn't that the situation we're already in? |
No - current implmentation is still inconsitent in that arrays are returned wrapped in a 'value' param. Ie
It would be more consitent to just return
ie always return a result array of objects Luigis proposal is also ok with me as it allows developers to finer control of the response. |
Please can we get this reopened or a new ticket created to implement luigis proposals. |
I like the "same for all results" approach - keeping things consistent between results with regards to the envelope makes it easier for developers to understand/diagnose/inspect values. |
Luigi's proposal gives developers the option for implementing whatever response structure you like. The existing envelop approach does not and also creates major and un resolvable inconsitencies between functions which return db.queries and functions which return custom built lists. |
In order to minimise back compatability issues, can we add a flag on Ofunction to signal how to serialise the function response. if this flag is missing then the old style is used, if the flag is there then the new style should be used. We could also havea global default properties as to whether new functions should use this flag by default, and also whether or not it should forced on existing functions as well. |
I was trying my hand at javascript functions in orient and let me just say I am majorly disappointed. I want to do something simple like load some results and inspect their properties. I can't figure out how to do that. It appears that if I look at a record in the JS function it's completely empty. However if I return it from the function it's all filled out with data, WTF? Also in the Studio testing functions that do things like queries across edges I don't get anything back, yet calling the same function with the same param on the rest api I get data, WTF? Consistency would be nice, but it seems you are consistent about one thing, being inconsistent. |
@optimuspaul it's hard to help you without any example... Could you provide what is working via REST and not in Studio? Something I can copy & paste on an empty db. |
@lvca of course you are right. Here is an example: make some stuff
I have a function
in the studio, on the function page, when I test the function with "aaa" as the fingerprint to check I get 0 results. But on the rest API I get:
When I run
Which does't seem quite right, is that json? Why didn't it make it look like other results? |
Follow up issue : #2983
create function toJSON,
toJSON :
try {
return JSON.parse("{"@rid":"#51:2051"}");
} catch(e) {
}
Runing under JDK1.7
[
{
"@Rid": "#51:2051"
}
]
Runing under JDK1.8
[
{
"@type": "d",
"@Version": 0,
"value": {
"@Rid": "#51:2051"
}
}
]
The text was updated successfully, but these errors were encountered: