Skip to content

AddField with type date and default value not working #1545

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

Closed
4 tasks done
mohamedGamalAbuGalala opened this issue Oct 18, 2021 · 3 comments · Fixed by #1544
Closed
4 tasks done

AddField with type date and default value not working #1545

mohamedGamalAbuGalala opened this issue Oct 18, 2021 · 3 comments · Fixed by #1544
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@mohamedGamalAbuGalala
Copy link

New Issue Checklist

Issue Description

When adding a new field with type Date and with defaultValue it complains that the defaultValue should be with type date.

Steps to reproduce



    const newLocalSchema = new Parse.Schema('BlaSchema')
    newLocalSchema.addField('bla', 'Date', { defaultValue: new Date() })
    await newLocalSchema.save()


Actual Outcome

error: Parse error:  schema mismatch for BlaSchema.bla default value; expected Date but got String {"code":111,"stack":"Error: schema mismatch for BlaSchema.bla default value; expected Date but got String\n    at SchemaController.addClassIfNotExists

image

Expected Outcome

It should work.

Environment

Server

  • Parse Server version: ^4.10.2
  • Operating system: Windows
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): Mongo
  • Database version: v5.0.2
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): docker

Client

  • Parse JS SDK version: 3.3.0

Logs

@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 18, 2021

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@mtrezza
Copy link
Member

mtrezza commented Oct 18, 2021

Not sure whether this is a Parse JS SDK issue, from the logs it looks like a Parse Server issue. I'm transferring the issue to the server repository. Could you open a PR with a failing test?

@mtrezza mtrezza transferred this issue from parse-community/Parse-SDK-JS Oct 19, 2021
@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Oct 19, 2021
@ghost
Copy link

ghost commented Apr 7, 2022

image

Please reference above content!
Thank you

@dblythy
Copy link
Member

dblythy commented Sep 14, 2022

@mtrezza after some tedious debugging I can confirm this is an SDK issue.

addDate('fieldName', {defaultValue}) works
addField('fieldName', 'Date', {defaultValue}) does not work

It will be a simple fix once transferred

@mtrezza mtrezza linked a pull request Sep 14, 2022 that will close this issue
4 tasks
@mtrezza mtrezza transferred this issue from parse-community/parse-server Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants