{"action":"opened","issue":{"url":"https://api.github.com/repos/waterlinejs/sqlite3-adapter/issues/12","repository_url":"https://api.github.com/repos/waterlinejs/sqlite3-adapter","labels_url":"https://api.github.com/repos/waterlinejs/sqlite3-adapter/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/waterlinejs/sqlite3-adapter/issues/12/comments","events_url":"https://api.github.com/repos/waterlinejs/sqlite3-adapter/issues/12/events","html_url":"https://github.com/waterlinejs/sqlite3-adapter/issues/12","id":161900904,"number":12,"title":"String values converted to date even when type is string","user":{"login":"KyleLilly","id":3723216,"avatar_url":"https://avatars.githubusercontent.com/u/3723216?v=3","gravatar_id":"","url":"https://api.github.com/users/KyleLilly","html_url":"https://github.com/KyleLilly","followers_url":"https://api.github.com/users/KyleLilly/followers","following_url":"https://api.github.com/users/KyleLilly/following{/other_user}","gists_url":"https://api.github.com/users/KyleLilly/gists{/gist_id}","starred_url":"https://api.github.com/users/KyleLilly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KyleLilly/subscriptions","organizations_url":"https://api.github.com/users/KyleLilly/orgs","repos_url":"https://api.github.com/users/KyleLilly/repos","events_url":"https://api.github.com/users/KyleLilly/events{/privacy}","received_events_url":"https://api.github.com/users/KyleLilly/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-23T11:33:05Z","updated_at":"2016-06-23T11:33:05Z","closed_at":null,"body":"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:\r\n```\r\nattributes: {\r\n  version: {\r\n    type: \"string\",\r\n    primaryKey: true,\r\n    required: true\r\n  },\r\n  description: {\r\n    type: \"string\"\r\n  }\r\n}\r\n```\r\nThe 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`. \r\n\r\nIdeally `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.\r\n\r\nI can send a PR if you want."}}
{"actor":{"display_login":"KyleLilly"}}