activerecord-turntable 4.2.0 → 4.3.0

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
  SHA256:
3
- metadata.gz: 4cced005d4106f1fe4e91d38fa233de92139928169754bb96303ab14e11e731b
4
- data.tar.gz: 80e4e77bcc89380430968ee18b5831667db76ca0872c734879456f9b9aacccdf
3
+ metadata.gz: 6d1d03f8216a73b1e732c4c1c22c6eda6d9843661121a2c5c85543ca6da51e32
4
+ data.tar.gz: e71f85959d36f0dbb806ed287ba9137a45c30645fdfafbf6d845799ab3de3fc0
5
5
  SHA512:
6
- metadata.gz: '04769f9f47f94395e4bb5fda699e4807ca992283f5cf2c11abab2cb498757bd8e07ff6062d4cf8f130f6ec3244f65c844347f95adbb5e967555560bca07b4b9d'
7
- data.tar.gz: 272bcec55c63d01b7488f5c480d0ce7dd77e0bfe57de18e3222736b5d838a53e460bee872e7040a29c6521541201fcfc70fda298bc636f02cf547cf98d995f98
6
+ metadata.gz: 2bffbb3be5a6d1ccd5f4fb69a7a6c4af0c41f63f56188e6aee394979d9310f37646243ef3e3b035bf28767a2c25b70d4b10bda9544f0070b232364834476a61f
7
+ data.tar.gz: 72c016be4117d12955f448aba07d3f02c2262fb590e8c3b2361aeae9a307aab3d588520e28da8d3e6cb421b9649e751a05ff901fdfe4a6349577f7505730b466
@@ -1,3 +1,10 @@
1
+ ## activerecord-turntable 4.3.0 ##
2
+
3
+ ### Bugfixes
4
+
5
+ * Fix `NoMethodError` on boot with production env
6
+ * Fix not working patches for activerecord-import
7
+
1
8
  ## activerecord-turntable 4.2.0 ##
2
9
 
3
10
  ### Major Changes
data/README.md CHANGED
@@ -27,7 +27,7 @@ MySQL only.
27
27
  Add to Gemfile:
28
28
 
29
29
  ```ruby
30
- gem 'activerecord-turntable', '~> 4.2.0'
30
+ gem 'activerecord-turntable', '~> 4.3.0'
31
31
  ```
32
32
 
33
33
  Run a bundle install:
@@ -3,10 +3,9 @@ module ActiveRecord::Turntable
3
3
  # activerecord-import extension
4
4
  module ActiverecordImportExt
5
5
  # @note override for sequencer injection
6
- # @see https://github.com/zdennis/activerecord-import/blob/b325ebb644160a09db6e269e414f33561cb21272/lib/activerecord-import/import.rb#L661-L689
6
+ # @see https://github.com/zdennis/activerecord-import/blob/85586d052822b8d498ced6c900251997edbeee04/lib/activerecord-import/import.rb#L848-L883
7
7
  private def values_sql_for_columns_and_attributes(columns, array_of_attributes)
8
8
  connection_memo = connection
9
- type_caster_memo = type_caster if respond_to?(:type_caster)
10
9
 
11
10
  array_of_attributes.map do |arr|
12
11
  my_values = arr.each_with_index.map do |val, j|
@@ -15,12 +14,16 @@ module ActiveRecord::Turntable
15
14
  # be sure to query sequence_name *last*, only if cheaper tests fail, because it's costly
16
15
  if val.nil? && column.name == primary_key && !sequence_name.blank?
17
16
  if sequencer_enabled?
18
- connection_memo.next_sequence_value(sequence_name)
17
+ self.next_sequence_value
19
18
  else
20
19
  connection_memo.next_value_for_sequence(sequence_name)
21
20
  end
21
+ elsif val.respond_to?(:to_sql)
22
+ "(#{val.to_sql})"
22
23
  elsif column
23
- connection_memo.quote(type_caster_memo.type_cast_for_database(column.name, val))
24
+ type = type_for_attribute(column.name)
25
+ val = type.type == :boolean ? type.cast(val) : type.serialize(val)
26
+ connection_memo.quote(val)
24
27
  end
25
28
  end
26
29
  "(#{my_values.join(',')})"
@@ -31,6 +34,8 @@ module ActiveRecord::Turntable
31
34
  begin
32
35
  require "activerecord-import"
33
36
  require "activerecord-import/base"
37
+ require "activerecord-import/active_record/adapters/mysql2_adapter"
38
+ ActiveRecord::Turntable::ConnectionProxy.include(ActiveRecord::Import::Mysql2Adapter)
34
39
  (class << ActiveRecord::Base; self; end).prepend(ActiverecordImportExt)
35
40
  rescue LoadError # rubocop:disable Lint/HandleExceptions
36
41
  end
@@ -11,8 +11,8 @@ module ActiveRecord::Turntable
11
11
  yield proxy
12
12
  end
13
13
 
14
- delegate :connected?, :automatic_reconnect, :automatic_reconnect=, :checkout_timeout, :dead_connection_timeout,
15
- :spec, :connections, :size, :reaper, :table_exists?, :query_cache_enabled, :enable_query_cache!, to: :proxy
14
+ delegate :connected?, :checkout_timeout, :automatic_reconnect, :automatic_reconnect=, :checkout_timeout, :checkout_timeout=, :dead_connection_timeout,
15
+ :spec, :connections, :size, :reaper, :table_exists?, :query_cache_enabled, :enable_query_cache!, :schema_cache, :schema_cache=, to: :proxy
16
16
 
17
17
  %w(columns_hash column_defaults primary_keys).each do |name|
18
18
  define_method(name.to_sym) do
@@ -30,18 +30,32 @@ module ActiveRecord::Turntable
30
30
  connection_pools_list.any?(&:active_connection?)
31
31
  end
32
32
 
33
- %w(disconnect!
34
- release_connection
35
- clear_all_connections!
36
- clear_active_connections!
37
- clear_reloadable_connections!
38
- clear_stale_cached_connections!
39
- verify_active_connections!).each do |name|
33
+ %w[
34
+ clear_active_connections!
35
+ clear_all_connections!
36
+ clear_reloadable_connections!
37
+ clear_stale_cached_connections!
38
+ disconnect
39
+ disconnect!
40
+ flush!
41
+ reap
42
+ release_connection
43
+ verify_active_connections!
44
+ ].each do |name|
40
45
  define_method(name.to_sym) do
41
46
  connection_pools_list.each { |cp| cp.public_send(name.to_sym) }
42
47
  end
43
48
  end
44
49
 
50
+ %w[
51
+ clear_reloadable_connections
52
+ flush
53
+ ].each do |name|
54
+ define_method(name.to_sym) do |args|
55
+ connection_pools_list.each { |cp| cp.public_send(name.to_sym, *args) }
56
+ end
57
+ end
58
+
45
59
  def discard!
46
60
  # Nothing to do
47
61
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Turntable
3
- VERSION = "4.2.0".freeze
3
+ VERSION = "4.3.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-turntable
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gussan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-21 00:00:00.000000000 Z
12
+ date: 2018-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord