Skip to content

Conversation

osyo-manga
Copy link
Collaborator

@osyo-manga osyo-manga commented May 14, 2019

Fixed a bug that swapped_id doesn't change after #reload.

before

class Company < ActiveRecord::Base
  include ActiveRecord::Bitemporal
end

company = Company.create(name: "Company")
Company.find(company.id).update(name: "NeoCompany")

pp company.name         # => "Company"
pp company.swapped_id   # => 1

company.reload

# Updated name
pp company.name         # => "NeoCompany"
# Not updated swapped_id
pp company.swapped_id   # => 1

after

class Company < ActiveRecord::Base
  include ActiveRecord::Bitemporal
end

company = Company.create(name: "Company")
Company.find(company.id).update(name: "NeoCompany")

pp company.name         # => "Company"
pp company.swapped_id   # => 1

company.reload

# Updated name
pp company.name         # => "NeoCompany"
# Updated swapped_id
pp company.swapped_id   # => 3

@auto-assign auto-assign bot requested review from meganemura and t-mori23 May 14, 2019 11:25
@osyo-manga
Copy link
Collaborator Author

😭

company = Company.create(name: "Company")
Company.find(company.id).update(name: "NeoCompany")
company.reload

pp company.swapped_id   # => 3
company.clear_changes_information
# Reset swapped_id after call `#clear_changes_information`
pp company.swapped_id   # => 1

@osyo-manga
Copy link
Collaborator Author

Fixed ⬆️

# NOTE: Hook to copying swapped_id
@_swapped_id = fresh_object.swapped_id
self
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osyo-manga
Copy link
Collaborator Author

@meganemura @t-mori23 Please reviewing 🙏

@osyo-manga osyo-manga changed the title [WIP] Add support changing swapped_id, when called # reload Add support changing swapped_id, when called # reload May 15, 2019
@t-mori23
Copy link

@osyo-manga
conflicted 😭
can you resolve it?

@osyo-manga osyo-manga force-pushed the change-swapped_id-when-called-reload branch from 2b017b7 to 8f2524d Compare May 17, 2019 02:48
@osyo-manga
Copy link
Collaborator Author

@t-mori23 oops, I fixed it. Thanks!

Copy link

@t-mori23 t-mori23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@meganemura meganemura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@osyo-manga
Copy link
Collaborator Author

@t-mori23 @meganemura Thanks!!!!

@osyo-manga osyo-manga merged commit 73e9526 into kufu:master May 17, 2019
@osyo-manga osyo-manga deleted the change-swapped_id-when-called-reload branch May 20, 2019 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants