Skip to content
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

[*] Default Values - Field DATEONLY with defaultValue shows incorrect data on form #164

Closed
doug2k1 opened this issue Feb 10, 2018 · 3 comments
Labels

Comments

@doug2k1
Copy link

doug2k1 commented Feb 10, 2018

Hi!

I have a model defined like this:

const BalanceUpdate = sequelize.define('BalanceUpdate', {
    amount: DataTypes.DECIMAL(10, 5),
    date: {
      type: DataTypes.DATEONLY,
      defaultValue: DataTypes.NOW
    }
  });

When I open the "create new" page, the Date field comes pre-filled with the contents: [object Object].

Expected behavior

The field should display the current date.

## Actual behavior

The field displays an invalid value, and if I try to save as is I get an error: invalid input syntax for type date: "Invalid date".

Failure Logs

23:38:38 web.1   |  Executing (default): INSERT INTO "BalanceUpdates" ("id","amount","date","createdAt","updatedAt","InvestmentId") VALUES (DEFAULT,3,'Invalid date','2018-02-10 01:38:37.426 +00:00','2018-02-10 01:38:37.426 +00:00','1') RETURNING *;

Context

  • Package Version: 2.4.2
  • Express Version: 4.16.2
  • Sequelize Version: 4.33.2
  • Database Dialect: postgres
  • Database Version: 10.1
@arnaudbesnier arnaudbesnier changed the title Field DATEONLY with defaultValue shows incorrect data on form [*] Default Values - Field DATEONLY with defaultValue shows incorrect data on form Feb 11, 2018
@arnaudbesnier
Copy link
Member

Hey @doug2k1, thanks for the feedback.

We definitely have an issue with "dynamic" default values like DataTypes.NOW.
This is not easy to handle with the current implementation.

A workaround would be to hide the field in Forest in the creation form, to let the creation work as expected. Let me know if that works for you.

@doug2k1
Copy link
Author

doug2k1 commented Feb 11, 2018

Hi, @arnaudbesnier. Thanks for the response.

Yes, hiding the field allows the creation, but that would not be an option for me, as in some cases I need to change the date.

There is a way to remove the defaultValue from the model definition, but still have some default pre-filled in the field, just on client side?

@arnaudbesnier
Copy link
Member

Hey @doug2k1, the [object Object] value should not be visible as the default value anymore if you use the latest liana version 2.8.3.

🌲🌲🌲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants