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

String values converted to date even when type is string #12

Open
KyleLilly opened this issue Jun 23, 2016 · 0 comments
Open

String values converted to date even when type is string #12

KyleLilly opened this issue Jun 23, 2016 · 0 comments

Comments

@KyleLilly
Copy link

The castValues function is converting string data that is parseable as a date via moment.js ie 20000101 to a date and returning a date object even when the model defines the column as a string:

attributes: {
  version: {
    type: "string",
    primaryKey: true,
    required: true
  },
  description: {
    type: "string"
  }
}

The issue really becomes a problem because moment.isValid() returns true for something like 20000101 but after running the replace on the value which is a string it's still a string and doing new Date(stripped).valueOf() results in NaN because the value "20000101" is not valid for a Date.

Ideally castValues would just return the string if the model type is string and if it's a date then moment should be used to do the parsing.

I can send a PR if you want.

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

No branches or pull requests

2 participants