This project is archived and is in readonly mode.
before_type_cast not available for datetime fields
-
Thijs van der Vossen
This issues also affects valid datetime values:
r = Recording.new
r.started_at = '2010-03-21T21:23:32+01:00'
r.started_at => Sun, 21 Mar 2010 20:23:32 UTC +00:00
r.started_at_before_type_cast => Sun, 21 Mar 2010 20:23:32 UTC +00:00 -
David Trasbo
Verified with Rails 2.3.5.
-
kdgundermann
what is expected for datetime_before_type_cast ??
- a String like "Sun, 21 Mar 2010 20:23:32 UTC +00:00" ( English time format )
- a String like "2010-03-21 20:23:32+00:00" ( another time format )
- a String like "21.03.2010 20:23:32" ( another time format for german locale )
- a String like "2010-03-21T20:23:32+00:00" ( a time format defined in ISO8601 )
- a Time object
-
Łukasz Strzałkowski
@kdgundermann: it's quite obvious for me - it should return the same thing that you set. It you set some FooBar class instance it should return it, etc.
I've checked this on master today and it works properly, wrote some tests for it and they pass (attached them. I think it would be good to push them to master to avoid regressions). Issue can affect only 2-3 branch. I have some problems running test on this branch, I'll check it tomorrow.
-
Akira Matsuda
- Tag changed from datetime, typecast to activerecord rails3, datetime, edge, patch, rails3.1, tested, typecast
I found this still is a problem on current Edge (3.1.0 beta).
So, here's a patch for the current master.
I haven't tested for 2.x yet, but am willing to work on 2.x branch as well, if you verify this patch on 3.x. -
Geoff Jacobsen
Can this patch also be applied to the 3.0 branch?
-
Akira Matsuda
It didn't actually cleanly apply, so I created another patch for 3-0-stable branch.
Could you try this one? -
Geoff Jacobsen
The diff applied cleanly and looks correct but I can't run the tests as I can't get "bundle install" to work against my version of ruby (1.9.2p94) and I can't get 1.9.2p0 to install on my computer.
-
Geoff Jacobsen
I managed to get 1.9.2p0 installed and all the rails3-0 active_record tests passed.
-
Repository
- State changed from new to committed
(from [817e37013610c8e8866197594d5e408b4d5daec5]) Make before_type_cast available for datetime fields
[#3973 before_type_cast not available for datetime fields state:committed]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/817e37013610c8e8866197594d5e4... -
Adam Meehan
I had my suspicions this patch was not working.
After playing around I confirmed that tests were not touching the changed code at all. This is because time_zone_aware_attributes setting was false. This meant the write method for created_at was not being generated using the timezone conversion method matcher. When switched to true the test broke.
I have attached a patch which fixes it and also cleaned up the test to make it more inline with the others test around timezone conversion.
-
Adam Meehan
The patch (bloody lighthouse!!)
-
Akira Matsuda
@Adam,
I guess we cannot upload a file to Lighthouse using Chrome or Safari. Can you try again on Firefox?
-
Adam Meehan
@Akira you're right I think. Driving me nuts!!
Finally, patch attached.
