You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Receiving a HTTP 500 when using a distinct query on nullable field #4540
Parse-Server responds with a HTTP 500 when using a distinct query on the _User table using a field which is set to null on one or more objects.
Steps to reproduce
Setup a new parse-server instance and add a field of the type String to the table. Create a new user and set the newly created field to null for the new user. Use the new distinct query feature on that field.
Expected Results
The server should return an array with all distinct strings
Actual Outcome
The server responds with a HTTP 500
Environment Setup
Server
parse-server version: 2.7.2
Operating System: Amazon Linux 2017.09 v4.4.4
Hardware: EC2 t2.micro
Localhost or remote server: AWS
Database
MongoDB version: 3.2.13
Storage engine: wiredTiger
Hardware: EC2 t2.micro
Localhost or remote server: AWS
Logs/Trace
Uncaught internal server error. TypeError: Cannot convert undefined or null to object
at cleanResultOfSensitiveUserInfo (/var/app/current/node_modules/parse-server/lib/RestQuery.js:422:10)
at config.database.find.then.results (/var/app/current/node_modules/parse-server/lib/RestQuery.js:499:9)
at process._tickDomainCallback (internal/process/next_tick.js:135:7) TypeError: Cannot convert undefined or null to object
at cleanResultOfSensitiveUserInfo (/var/app/current/node_modules/parse-server/lib/RestQuery.js:422:10)
at config.database.find.then.results (/var/app/current/node_modules/parse-server/lib/RestQuery.js:499:9)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
@flovilmart I have a PR ready for this but I wanted to verify something. I noticed a difference when setting a field from a value to null or undefined.
When using null the field is set.
{ $set: { fieldName: null, _updated_at: ... } }
When using undefined the field isn't updated.
{ $set: { _updated_at: ... } }
Is this proper behavior? This is specific for Mongo, they both update when using PG
how do we get a field back to 'undefined' when using unset in js sdk? now it sets it to null which isnt the same and breaks older versions. @flovilmart
Activity
dplewis commentedon Feb 2, 2018
Good catch! Would you like to open a PR for this issue?
dplewis commentedon Feb 8, 2018
@flovilmart I have a PR ready for this but I wanted to verify something. I noticed a difference when setting a field from a value to null or undefined.
When using null the field is set.
When using undefined the field isn't updated.
Is this proper behavior? This is specific for Mongo, they both update when using PG
flovilmart commentedon Feb 8, 2018
it boils down to bottom values, undefined is not serialized, this is an unset, in PG null or unset is the same right?
j-koenig commentedon Feb 16, 2018
@dplewis Sorry for not answering to your message and thanks for the PR :)
jeffreyjackson commentedon Apr 2, 2018
how do we get a field back to 'undefined' when using unset in js sdk? now it sets it to null which isnt the same and breaks older versions. @flovilmart