Skip to content

Commit

Permalink
do not sync data if table does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
bdurand committed Oct 28, 2022
1 parent a6e3cbf commit 9c10a01
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/support_table_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module ClassMethods
#
# @return [Array<Hash>] List of saved changes for each record that was created or modified.
def sync_table_data!
return unless table_exists?

key_attribute = (support_table_key_attribute || primary_key).to_s
canonical_data = support_table_data.each_with_object({}) { |attributes, hash| hash[attributes[key_attribute].to_s] = attributes }
records = where(key_attribute => canonical_data.keys)
Expand Down

0 comments on commit 9c10a01

Please sign in to comment.