activerecord-mysql2-adapter-patch 5.1.4 → 6.0.2.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
  SHA256:
3
- metadata.gz: b95d1e157dec066675446a293b0ecb6ec8a5368143a7266b4eb789cfb9d30e8e
4
- data.tar.gz: c4de7c524b1e42e06aa44fa87bcbd8fa3aeb26b0c4d5696613b0d3c2983aa22f
3
+ metadata.gz: 5e065a634213af40b0697588e4284a998e82a748272030f99dc44bb664b779e5
4
+ data.tar.gz: 4b4bf1b0e02da1ae82116ebe240b712e5fbff8b53fbda257943230470201b20b
5
5
  SHA512:
6
- metadata.gz: 755bd921f59c02db3ee8c6f4806983d0923a6af119206c2dcfce9be2d2214584f9a19b788332daca4f205182cd9460da10fa84f365264e79d8827526d4c3d100
7
- data.tar.gz: 7b44323c8202c123b1f8bed6f012ab32c06de35019a0a9e4d8d516e1c0bb0228f2b089082b1d69b742c6751fd810fe58046f32ad1932ca3ad84259d1582ac883
6
+ metadata.gz: 4d31e26644f4ea86826cc135da68e80aba4ee2449dd581ee2ebda1c8d0ec3478eaa811428aaa0fbc382ad5ee5e1bf15ae0daa7d5c4cce798538601df6fa32a63
7
+ data.tar.gz: c645053b20217490df7b0f4552e2a502d8adb4f29d8622ce781434ef5f7a47c6215aebde0ef36df522a179e30f507247e3801b0231488ea9341839bf71bbf333
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'activerecord-mysql2-adapter-patch'
5
- s.version = '5.1.4'
5
+ s.version = '6.0.2.2'
6
6
  s.licenses = ['MIT']
7
7
  s.summary = 'ActiveRecord Mysql2 Adapater batch for datetime on update'
8
8
  s.description = 'Fixes schema.rb for datetime fields that use on update'
@@ -4,14 +4,26 @@ require 'active_record'
4
4
  require 'active_record/connection_adapters/abstract_mysql_adapter'
5
5
 
6
6
  class ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
7
- def new_column_from_field(table_name, field) # :nodoc:
7
+ def new_column_from_field(table_name, field)
8
8
  type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
9
- if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\(\))?\z/i.match?(field[:Default])
10
- default, default_function = nil, "CURRENT_TIMESTAMP"
9
+ default, default_function = field[:Default], nil
10
+
11
+ if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(default)
12
+ default, default_function = nil, default
11
13
  default_function += ' ' + field[:Extra] if field[:Extra] != ''
12
- else
13
- default, default_function = field[:Default], nil
14
+ elsif type_metadata.extra == "DEFAULT_GENERATED"
15
+ default = +"(#{default})" unless default.start_with?("(")
16
+ default, default_function = nil, default
14
17
  end
15
- new_column(field[:Field], default, type_metadata, field[:Null] == "YES", table_name, default_function, field[:Collation], comment: field[:Comment].presence)
18
+
19
+ MySQL::Column.new(
20
+ field[:Field],
21
+ default,
22
+ type_metadata,
23
+ field[:Null] == "YES",
24
+ default_function,
25
+ collation: field[:Collation],
26
+ comment: field[:Comment].presence
27
+ )
16
28
  end
17
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysql2-adapter-patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.4
4
+ version: 6.0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch