Page 2 of 2

(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 2:25 pm
by Kal

Yes, Yurii, I did read your reply carefully. It is a very creative idea to create two columns called "where" and "operations" and update them with those values, but totally misses the point of what we are trying to do here!

As to where I got the information about "where" clause in update service: it is in your documentation: http://devcenter.appery.io/documentat...

In particular, please read the following sentence:
"Conditional multiple objects update

By mixing where and operations parameters, you can conditionally update multiple objects."

I use this ALL THE TIME on the client side, and it works perfectly well. I created a test app to prove it for you, here is the screenshot of the app.
Image

In this app, there is an update service that has a "where" clause and a "operations.$set" clause, as shown in the following screenshot:
Image
In the app, you can enter a name on one field, and a value in another, click on update. It will update ALL rows in the DB that have that name. It works perfectly fine.

I have shared the project with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a, and the project is called TestWhereUpdate. You can play with it to satisfy that it works.

Now, the REAL question: Why does it work from the Client side REST service, but NOT from the server-side REST service?


(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 3:36 pm
by Kal

Is there a way to update this thread from "Question" status to "Problem" status. This is definitely a problem for me now. I will be happy to open up a new thread, if required.


(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 3:53 pm
by Kateryna Grynko

Hi Kal,

Done. Working on it.


(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 4:19 pm
by Kal

Thanks, Katya. I have also shared a Server Side test script with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a. This script should be doing exactly what the client side does, but fails with the DBSP007 error. Script is called TestUpdateScript


(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 5:35 pm
by Kal

Also shared the associated DB, just in case you need it.


(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 5:49 pm
by Kateryna Grynko

Hi Kal,

Thank you, we'll test this.


(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 11:49 pm
by Yurii Orishchuk

Hi Kal,

Sorry, my bad.

So i've checked your server code script and here is worked code for you:

pre

var responseBody = {},
requestParams = {},
paramKeys = request.keys();

for (var key = 0; key < paramKeys&#46;length; key++) {
requestParams[paramKeys[key]] = request&#46;get(paramKeys[key]);
}

var dbId = "53eae11fe4b0d1037ddcbeed";

var bodyObject = {
"where": {"name":"joe"},
"operations": {"$set":{"value":"42_1"}}
};

var XHRResponse = XHR&#46;send("PUT", "https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/collections/MyCollection/", {
"headers": {
"X-Appery-Database-Id": dbId,
"Content-Type": "application/json"
},
&#47;&#47;"body": {
&#47;&#47; "where": '{"name":"joe"}',
&#47;&#47; "operations": '{"$set":{"value":"42"}}'
&#47;&#47;}

"body": JSON&#46;stringify(bodyObject)
});
console&#46;log(XHRResponse);

/pre

Regards.


(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 11:58 pm
by axkrishnan

Aha! So you were on the right track with your first idea. There was a serialization error because it was expecting JSON and getting a string. Good catch!


(undocumented) database REST error code: 'DBSP007', description: 'Serialization error'

Posted: Wed Aug 13, 2014 11:59 pm
by Kal

YES! That works, thanks.