Skip to content

Commit

Permalink
Revert "Merge pull request #6986 from kennyj/fix_6975"
Browse files Browse the repository at this point in the history
This reverts commit 8905c1f.

Closes #8460

Conflicts:
	activerecord/test/cases/dirty_test.rb
  • Loading branch information
pixeltrix committed Jan 22, 2013
1 parent 7ee7671 commit 97a4db9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
5 changes: 5 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Rails 3.2.12 (unreleased) ##

* Revert round usec when comparing timestamp attributes in the dirty tracking.
Fixes #8460.

*Andrew White*

* Revert creation of through association models when using `collection=[]`
on a `has_many :through` association from an unsaved model.
Fix #7661, #8269.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ def #{attr_name}=(original_time)
unless time.acts_like?(:time)
time = time.is_a?(String) ? Time.zone.parse(time) : time.to_time rescue time
end
zoned_time = time && time.in_time_zone rescue nil
rounded_time = round_usec(zoned_time)
rounded_value = round_usec(read_attribute("#{attr_name}"))
if (rounded_value != rounded_time) || (!rounded_value && original_time)
write_attribute("#{attr_name}", original_time)
#{attr_name}_will_change!
@attributes_cache["#{attr_name}"] = zoned_time
end
time = time.in_time_zone rescue nil if time
changed = read_attribute(:#{attr_name}) != time
write_attribute(:#{attr_name}, original_time)
#{attr_name}_will_change! if changed
@attributes_cache["#{attr_name}"] = time
end
EOV
generated_attribute_methods.module_eval(method_body, __FILE__, line)
Expand All @@ -63,12 +60,6 @@ def create_time_zone_conversion_attribute?(name, column)
time_zone_aware_attributes && !self.skip_time_zone_conversion_for_attributes.include?(name.to_sym) && column.type.in?([:datetime, :timestamp])
end
end

private
def round_usec(value)
return unless value
value.change(:usec => 0)
end
end
end
end
15 changes: 0 additions & 15 deletions activerecord/test/cases/dirty_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -563,21 +563,6 @@ def test_datetime_attribute_can_be_updated_with_fractional_seconds
end
end

def test_setting_time_attributes_with_time_zone_field_to_same_time_should_not_be_marked_as_a_change
in_time_zone 'Paris' do
target = Class.new(ActiveRecord::Base)
target.table_name = 'pirates'

created_on = Time.now

pirate = target.create(:created_on => created_on)
pirate.reload # Here mysql truncate the usec value to 0

pirate.created_on = created_on
assert !pirate.created_on_changed?
end
end

private
def with_partial_updates(klass, on = true)
old = klass.partial_updates?
Expand Down

0 comments on commit 97a4db9

Please sign in to comment.