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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e065a634213af40b0697588e4284a998e82a748272030f99dc44bb664b779e5
|
4
|
+
data.tar.gz: 4b4bf1b0e02da1ae82116ebe240b712e5fbff8b53fbda257943230470201b20b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
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)
|
7
|
+
def new_column_from_field(table_name, field)
|
8
8
|
type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
default
|
14
|
+
elsif type_metadata.extra == "DEFAULT_GENERATED"
|
15
|
+
default = +"(#{default})" unless default.start_with?("(")
|
16
|
+
default, default_function = nil, default
|
14
17
|
end
|
15
|
-
|
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
|