-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
Query fails when an array column contains objects with dates. I have been able to isolate the data that generates the problem (see below). The problem does not occur with hosted-parse. The problem seems to be due to node modules based on the log information (see below).
The date formatting seems to be the issue:
- Does not work: iso: ISODate("2014-11-15T07:35:03Z")
- Works: iso: "2014-11-15T07:35:03Z"
The following is a closed issue which seems related but there was no resolution.
#1077
Steps to reproduce
- Run query find or get locally or via cloud code.
var Obj = Parse.Object.extend("Clock");
var query = new Parse.Query(Obj);
query.equalTo("objectId","2iVREi5Kiu");
query.find().then(function(result) {
res.success(result);
}, function(error) {
res.error(error);
});
OR
query.get("2iVREi5Kiu").then(function(result) {
console.log(result);
}, function(error) {
console.log(error);
});
Expected Results
I expect the result field "history" to contain an array with an object that contains 2 dates. Instead the query fails.
[{ date: [should be a valid date],
event: 'Clock In - Sick Leave',
from: 'None',
to: [should be a valid date],
type: 'date',
who: 'Brian Login' }]
Actual Outcome
Console Log - Cloud
{code: 141, message: {}}
Console Log - Local
{className: "Error", _objCount: 8}
Console Log - Server
[{ date: Invalid Date,
event: 'Clock In - Sick Leave',
from: 'None',
to: Invalid Date,
type: 'date',
who: 'Brian Login' }]
CURL Results
curl -X GET
-H "X-Parse-Application-Id: xxx"
-H "X-Parse-Master-Key: xxx"
-G
--data-urlencode "where={"objectId":"2iVREi5Kiu"}"
https://xxx.nodechef.com/parse/classes/Clock
[{
"date": {
"__type": "Date",
"iso": {
"__type": "Date",
"iso": "2014-11-15T07:35:03.000Z"
}
},
"event": "Clock In - Sick Leave",
"from": "None",
"to": {
"__type": "Date",
"iso": {
"__type": "Date",
"iso": "2014-11-14T21:00:00.000Z"
}
},
"type": "date",
"who": "Brian Login"
}]
Stored Data - That Does Not Work
[{
date: {
__type: "Date",
iso: ISODate("2014-11-15T07:35:03Z")
},
event: "Clock In - Sick Leave",
from: "None",
to: {
iso: ISODate("2014-11-14T21:00:00Z"),
__type: "Date"
},
type: "date",
who: "Brian Login"
}]
Stored Data - That Will Work
[{
who: "Brian Login",
date: {
__type: "Date",
iso: "2014-11-15T02:35:03.026Z"
},
event: "Clock In - Sick Leave",
from: "None",
to: {
__type: "Date",
iso: "2014-11-14T16:00:00.000Z"
},
type: "date"
}]
Environment Setup
-
Server
- parse-server version: 2.3.2
- Node: Tried with 4.3.0, 4.3.2 and 6.9.4. The logs are from 6.9.4.
- Parse JS SDK: 1.9.2
- Operating System: OSX 10.11.6
- Hardware: MacBook Pro
- Localhost or remote server? Localhost
-
Database
- MongoDB version: Unknown
- Storage engine: RocksDb
- Hardware: Unknown
- Localhost or remote server? NodeChef
Logs/Trace
Error generating response. ParseError {
code: 141,
message:
Error: Tried to encode an invalid date.
at encode (/Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/encode.js:81:13)
at encode (/Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/encode.js:98:19)
at /Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/encode.js:91:14
at Array.map (native)
at encode (/Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/encode.js:90:18)
at exports.default (/Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/encode.js:16:10)
at Object.commitServerChanges (/Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/ObjectStateMutations.js:161:39)
at Object.commitServerChanges (/Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/UniqueInstanceStateController.js:162:24)
at ParseObjectSubclass.value (/Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/ParseObject.js:394:23)
at Function.value (/Users/brianmcgrath/parse-server-example/node_modules/parse-server/node_modules/parse/lib/node/ParseObject.js:1554:9) } code=141,
[object Object]