This project is archived and is in readonly mode.
AR:Base mangles dates when user submits only part of the fields
-
Martijn Vos
This patch fixes the problem. For me at least -- it's likely there are use cases I'm not aware of.
The patch doesn't add or update any tests because I couldn't find any relevant ones, and I'm not very familiar with these tests yet. This is my first Rails patch. Please check carefully.
The patch is also in http://github.com/mcv/rails/comm...
-
Pratik
- State changed from new to incomplete
- Assigned user set to Michael Koziarski
Patch is missing tests.
Thanks.
-
CancelProfileIsBroken
- Tag changed from activecord, bug, date to activecord, bug, bugmash, date
-
Hugo Peixoto
-1 for the patch, as it breaks two of the current tests.
Throws an ActiveRecord::MultiparameterAssignmentErrors exception when the day is set "", because it tries to execute Date.new(2004, 12, 0), which is invalid. It also breaks when every parameter is set to "", because it executes Date.new(0, 0, 0), which is also invalid.
-
Hugo Peixoto
Actually, according to date_select,
NOTE: Discarded selects will default to 1. So if no month select is available, January will be assumed.So I've attached a patch that respects this behaviour, with additional tests, checking many combinations of empty values.
-
Rizwan Reza
verified
This patch applies cleanly to 2-3-stable. All tests pass.
-
Elad Meidar
+1 Verified, +1 patch. applies on 2-3-stable and master with all tests pass
-
Repository
- State changed from incomplete to committed
(from [2c4f4a8734b4137adc331186bb2255fb6a38c31e]) With multiparameter date attributes, the behaviour when empty fields are present is now coherent with the one described in the date_select documentation.
[#1715 AR:Base mangles dates when user submits only part of the fields state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/2c4f4a8734b4137adc331186bb2255... -
Repository
(from [870750ed4b1e0b0e574aaec86db3e2cdf94b1190]) With multiparameter date attributes, the behaviour when empty fields are present is now coherent with the one described in the date_select documentation.
[#1715 AR:Base mangles dates when user submits only part of the fields state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/870750ed4b1e0b0e574aaec86db3e2... -
CancelProfileIsBroken
- Assigned user cleared.
- Tag changed from activecord, bug, bugmash, date to activecord, bug, date
- Milestone cleared.
-
Raimonds Simanovskis
These new tests fail on Oracle database (using oracle_enhanced adapter) because Oracle adapter by default returns date values as Time values and for Time values execute_callstack_for_multiparameter_attributes method does not replace missing values with 1.
-
Pratik
Hey Raimonds,
If you have a patch ready, I'll be happy to push.
Thanks.
-
Raimonds Simanovskis
I modified the test so that using Oracle enhanced adapter attribute type is forced to Date and now tests are passing: http://github.com/rsim/rails/commit/416d6cc51a6c67a89a564c86de8fede...
But the question remains is it necessary to substitute missing values with 1 when using datetime_select to assign values to Time attribute. Currently it seems that in such case result is unpredictable but in this case nothing is told in API documentation :)
