getoutreach / epf

A framework for keeping your Ember.js apps in sync.
http://epf.io
MIT License
369 stars 33 forks source link

Solves a bug in date transform (for newly created date properties) #111

Closed manuelmitasch closed 10 years ago

manuelmitasch commented 10 years ago

Previously the date transform serialize method excepted a Date object only. This resulted in a null value in the payload if a new record was saved (session.flush).

With this commit it tries to create a new Date object if a string or number are passed. Thus, serialization of newly created date properties should work now.

ghempton commented 10 years ago

Can you add a failing test?

manuelmitasch commented 10 years ago

As the transform code is borrowed from Ember Date this should also be an issue there. This seems related even thought outdated due to the transform rewrite: https://github.com/emberjs/data/pull/258

I believe it should be possible to use the date attribute without creating a Date object in a view.

Just wrote my first lines of coffeescript and mocha for the test ;)

ghempton commented 10 years ago

I have drastically overhauled the serialization layer in epf and this pull request no longer merges cleanly. In my opinion, however, this PR should not be merged. The serialize method should only take valid values returned by deserialize. In this case, deserialize always returns date objects.

ghempton commented 10 years ago

Thanks for the PR though! One solution to your use case would be to create a custom "date string" serializer that deals with strings.