active_record_shards 3.6.1 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dd69ed02637e49d444f17f46112f4353bd38274
4
- data.tar.gz: 72b1d921a77e347f093d0591b46a4c0dd088cb4e
3
+ metadata.gz: f22328837e48da3dbf1b805e69a7f65ad8ae431b
4
+ data.tar.gz: 5f64e2de4f4d9b2ec578a7086ca1b343199692af
5
5
  SHA512:
6
- metadata.gz: 25977dee6f8cd3188d6e7577c987a86c30e22b0ac2ee327dd9dccb07fb38bbe925c138497fc15caa1252fe6320cf849740d208abf09a04f8ee0deee2a654adf6
7
- data.tar.gz: 000d3325d3934d6b3c4655860edfe512970a0eceac91236dc4064eb9fa5775652df3e283bba0fb232b18c08a40eaada26c1c66b93d3344e70193b971da7e3b59
6
+ metadata.gz: 1208459ce41631737cc65189ffe6fe94bad6e7441442cb61330647308a3422c8475fbf2d84a63549493c23eda176b6a70476a7a5dffc7f68f25608e0d2b3061e
7
+ data.tar.gz: 40f8b499653ef50efe49fb465c69b021f29069997df42a037788893673c03eb22d1651d1e17df281f1abba83a82b1bb9fa49bc9ada607138c5fa11243dc1dcc0
@@ -39,12 +39,12 @@ module ActiveRecordShards
39
39
  self.configurations_without_shard_explosion = explode(conf)
40
40
  end
41
41
 
42
- def ConfigurationParser.extended(klass)
43
- klass.singleton_class.send(:alias_method, :configurations_without_shard_explosion=, :configurations=)
44
- klass.singleton_class.send(:alias_method, :configurations=, :configurations_with_shard_explosion=)
45
- klass.singleton_class.send(:public, :configurations=)
42
+ def self.extended(base)
43
+ base.singleton_class.send(:alias_method, :configurations_without_shard_explosion=, :configurations=)
44
+ base.singleton_class.send(:alias_method, :configurations=, :configurations_with_shard_explosion=)
45
+ base.singleton_class.send(:public, :configurations=)
46
46
 
47
- klass.configurations = klass.configurations if klass.configurations.present?
47
+ base.configurations = base.configurations if base.configurations.present?
48
48
  end
49
49
  end
50
50
  end
@@ -4,12 +4,12 @@ module ActiveRecordShards
4
4
  module ConnectionSwitcher
5
5
  SHARD_NAMES_CONFIG_KEY = 'shard_names'.freeze
6
6
 
7
- def self.extended(klass)
8
- klass.singleton_class.send(:alias_method, :columns_without_default_shard, :columns)
9
- klass.singleton_class.send(:alias_method, :columns, :columns_with_default_shard)
7
+ def self.extended(base)
8
+ base.singleton_class.send(:alias_method, :columns_without_default_shard, :columns)
9
+ base.singleton_class.send(:alias_method, :columns, :columns_with_default_shard)
10
10
 
11
- klass.singleton_class.send(:alias_method, :table_exists_without_default_shard?, :table_exists?)
12
- klass.singleton_class.send(:alias_method, :table_exists?, :table_exists_with_default_shard?)
11
+ base.singleton_class.send(:alias_method, :table_exists_without_default_shard?, :table_exists?)
12
+ base.singleton_class.send(:alias_method, :table_exists?, :table_exists_with_default_shard?)
13
13
  end
14
14
 
15
15
  def default_shard=(new_default_shard)
@@ -101,16 +101,17 @@ module ActiveRecordShards
101
101
 
102
102
  migrate_without_forced_shard(direction)
103
103
  end
104
+
105
+ def migration_shard
106
+ self.class.migration_shard
107
+ end
104
108
  end
105
109
  end
106
110
 
107
111
  ActiveRecord::Migration.class_eval do
108
112
  extend ActiveRecordShards::MigrationClassExtension
109
-
110
113
  include ActiveRecordShards::ActualMigrationExtension
111
- define_method :migration_shard do
112
- self.class.migration_shard
113
- end
114
+
114
115
  alias_method :migrate_without_forced_shard, :migrate
115
116
  alias_method :migrate, :migrate_with_forced_shard
116
117
  end
@@ -0,0 +1,34 @@
1
+ unless (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR > 2) || ActiveRecord::VERSION::MAJOR > 4
2
+ ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do
3
+ attr_accessor :schema_cache
4
+
5
+ private
6
+
7
+ alias :original_new_connection :new_connection
8
+
9
+ def new_connection
10
+ original_new_connection.tap do |connection|
11
+ if schema_cache
12
+ connection.schema_cache = schema_cache.dup
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ ActiveRecord::ConnectionAdapters::SchemaCache.class_eval do
19
+ def initialize_dup(other)
20
+ super
21
+
22
+ @columns = @columns.dup
23
+ @columns_hash = @columns_hash.dup
24
+ @primary_keys = @primary_keys.dup
25
+ @tables = @tables.dup
26
+ end
27
+ end
28
+ end
29
+
30
+ unless ActiveRecord::VERSION::MAJOR > 4
31
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
32
+ attr_writer :schema_cache
33
+ end
34
+ end
@@ -33,9 +33,10 @@ module ActiveRecordShards
33
33
  the_shard = shard(klass)
34
34
 
35
35
  @shard_names ||= {}
36
- @shard_names[the_shard] ||= {}
37
- @shard_names[the_shard][try_slave] ||= {}
38
- @shard_names[the_shard][try_slave][@on_slave] ||= begin
36
+ @shard_names[ActiveRecordShards.rails_env] ||= {}
37
+ @shard_names[ActiveRecordShards.rails_env][the_shard] ||= {}
38
+ @shard_names[ActiveRecordShards.rails_env][the_shard][try_slave] ||= {}
39
+ @shard_names[ActiveRecordShards.rails_env][the_shard][try_slave][@on_slave] ||= begin
39
40
  s = ActiveRecordShards.rails_env.dup
40
41
  s << "_shard_#{the_shard}" if the_shard
41
42
  s << "_slave" if @on_slave && try_slave
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_shards
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-22 00:00:00.000000000 Z
13
+ date: 2016-02-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -170,6 +170,7 @@ files:
170
170
  - lib/active_record_shards/default_slave_patches.rb
171
171
  - lib/active_record_shards/migration.rb
172
172
  - lib/active_record_shards/model.rb
173
+ - lib/active_record_shards/schema_cache_extension.rb
173
174
  - lib/active_record_shards/schema_dumper_extension.rb
174
175
  - lib/active_record_shards/shard_selection.rb
175
176
  - lib/active_record_shards/shard_support.rb