activerecord-import 0.20.1 → 0.20.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d7e1b67259d7a4d62e746876dfd781042aadba1
4
- data.tar.gz: 3eedcc2001fae319e4867e292843a23c2bec1223
3
+ metadata.gz: aedb604a103a355bb35e3373239fb12e1e9877cd
4
+ data.tar.gz: 235a13a5819d9181aaa478686ec42596c54806fe
5
5
  SHA512:
6
- metadata.gz: 28a9b68a29cb302d421051b406989211926e7b65c6e9edba0a016787a33c23d8e8e3ba76b21946eeb7241014c17786e95213a6e65a9d72589c4c12e8cbf41864
7
- data.tar.gz: aa61794f8678bb6ef3ebfc5d75728029f13ac1b87147cb1156bc414deaa8788c2fd08ed88d0ecd71963c4ee42a58d1d140ca80b7783d376238877435560a8a03
6
+ metadata.gz: 8e9349db11dd48246fb292215d4dd43efd2c8fe0c2e544e6fa585d4ad0aa7eb2ba612d8b7a84bbbaf991958b8c7897135314c6e73b4520d05a31861ec68ba5e7
7
+ data.tar.gz: 58de95004307eb2cfe48d0a6e534313612ed90c69df08e1bdb0372cb065d857189d23fa12552d652d0fbfb4a7ba91cedcba8c7c14c44dfd72c5bff26442bf0bd
@@ -1,3 +1,9 @@
1
+ ## Changes in 0.20.2
2
+
3
+ ### Fixes
4
+
5
+ * Unscope model when synchronizing with database. Thanks to @indigoviolet via \#455.
6
+
1
7
  ## Changes in 0.20.1
2
8
 
3
9
  ### Fixes
@@ -31,7 +31,7 @@ module ActiveRecord # :nodoc:
31
31
 
32
32
  klass = instances.first.class
33
33
 
34
- fresh_instances = klass.where(conditions).order(order)
34
+ fresh_instances = klass.unscoped.where(conditions).order(order)
35
35
  instances.each do |instance|
36
36
  matched_instance = fresh_instances.detect do |fresh_instance|
37
37
  keys.all? { |key| fresh_instance.send(key) == instance.send(key) }
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Import
3
- VERSION = "0.20.1".freeze
3
+ VERSION = "0.20.2".freeze
4
4
  end
5
5
  end
@@ -13,6 +13,8 @@ class Topic < ActiveRecord::Base
13
13
 
14
14
  composed_of :description, mapping: [%w(title title), %w(author_name author_name)], allow_nil: true, class_name: "TopicDescription"
15
15
 
16
+ default_scope { where(approved: true) }
17
+
16
18
  private
17
19
 
18
20
  def word_count
@@ -30,4 +30,12 @@ describe ".synchronize" do
30
30
  assert_equal false, topics[1].changed?, "the second record was dirty"
31
31
  assert_equal false, topics[2].changed?, "the third record was dirty"
32
32
  end
33
+
34
+ it "ignores default scope" do
35
+ # update records outside of ActiveRecord knowing about it
36
+ Topic.connection.execute( "UPDATE #{Topic.table_name} SET approved='0' WHERE id=#{topics[0].id}", "Updating record 1 without ActiveRecord" )
37
+
38
+ Topic.synchronize topics
39
+ assert_equal false, topics[0].approved
40
+ end
33
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-import
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-19 00:00:00.000000000 Z
11
+ date: 2017-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord