Description
New Issue Checklist
- [ x] I am not disclosing a vulnerability.
- [ x] I am not just asking a question.
- [ x] I have searched through existing issues.
- [x ] I can reproduce the issue with the latest version of Parse Server and the Parse Flutter SDK.
Issue Description
if I build this query:
query.exists('birthDate');
See the output:
catalunha@pop-os:~/myapp/contactlist01js$ node index.js
open...
{
birthDate: { __type: 'Date', iso: '2022-05-11T23:48:00.000Z' },
name: 'Ana',
isMan: false,
createdAt: '2022-05-11T23:48:28.834Z',
updatedAt: '2022-05-11T23:48:28.834Z',
objectId: 'GxxCRLf9Vo'
}
{
name: 'Barros',
isMan: false,
createdAt: '2022-05-11T23:48:51.054Z',
updatedAt: '2022-05-12T00:20:34.344Z',
birthDate: { __type: 'Date', iso: '2022-05-12T00:20:00.000Z' },
objectId: 'EDhtmzJnGR'
}
contact.id: EDhtmzJnGR | leave...
{
birthDate: { __type: 'Date', iso: '2022-05-11T23:48:00.000Z' },
name: 'Ana',
isMan: false,
createdAt: '2022-05-11T23:48:28.834Z',
updatedAt: '2022-05-11T23:48:28.834Z',
objectId: 'GxxCRLf9Vo'
}
contact.id: EDhtmzJnGR | enter...
{
birthDate: { __type: 'Date', iso: '2022-05-11T23:48:00.000Z' },
name: 'Ana',
isMan: false,
createdAt: '2022-05-11T23:48:28.834Z',
updatedAt: '2022-05-11T23:48:28.834Z',
objectId: 'GxxCRLf9Vo'
}
{
name: 'Barros',
isMan: false,
createdAt: '2022-05-11T23:48:51.054Z',
updatedAt: '2022-05-12T00:25:34.959Z',
birthDate: '2022-05-12T00:25:00.000Z',
objectId: 'EDhtmzJnGR'
}
As the column/field is involved in the query, Parse returns it in String format and not Date.
Strange agree?
Steps to reproduce
const Parse = require('parse/node');
Parse.serverURL = '...';
Parse.initialize('...','...');
const main = async ()=>{
const query = new Parse.Query('Contact');
query.exists('birthDate');
const subscribe = await query.subscribe();
let contacts = {};
const printContacts = ()=>{
console.log();
Object.keys(contacts).forEach(id=>{
console.log(contacts[id].toJSON());
});
console.log();
};
subscribe.on('open', async ()=>{
console.log('open...');
contacts = (await query.find()).reduce((contacts,contact)=>({
...contacts,
[contact.id]: contact
}),contacts);
printContacts();
});
subscribe.on('create',(data)=>{
console.log(`Data: ${data.id} | create...`);
contacts[data.id]=data;
printContacts();
});
subscribe.on('update',(data)=>{
console.log(`Data: ${data.id} | update...`);
contacts[data.id]=data;
printContacts();
});
subscribe.on('enter',(data)=>{
console.log(`Data: ${data.id} | enter...`);
contacts[data.id]=data;
printContacts();
});
subscribe.on('leave',(data)=>{
console.log(`Data: ${data.id} | leave...`);
delete contacts[data.id];
printContacts();
});
subscribe.on('delete',(data)=>{
console.log(`Data: ${data.id} | delete...`);
delete contacts[data.id];
printContacts();
});
subscribe.on('closed',()=>{
console.log('closed...');
});
};
main();
Actual Outcome
But Parse's default Date format is:
birthDate: { __type: 'Date', iso: '2022-05-11T23:48:00.000Z' },
Just because this column goes to query it has another type, in this case String ?
birthDate: '2022-05-12T00:25:00.000Z',
I find this complicated!
Because regardless of my consumption it is reporting data in different formats. Do you agree?
Expected Outcome
In any case, inside or outside of liveQuery, the date format is:
birthDate: { __type: 'Date', iso: '2022-05-11T23:48:00.000Z' },
Environment
Parse Flutter SDK
- SDK version:
parse_server_sdk_flutter: ^3.1.0
- Operating system version:
Linux PopOS
Server
I'm using back4app.com
- Parse Server version:
4.5.0
Logs
There is no error. Just the return with different types.