activerecord-mysql2-adapter-patch 0.1.0 → 5.1.4

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: fe3eb6f1ddca11cec8e68151f8d0902f9f399523fd5d35e23248e275b552ded9
4
- data.tar.gz: 599b89dc003a8b59d46e7fae32380b1220ae8cfc3a2868573afa63398177c545
3
+ metadata.gz: b95d1e157dec066675446a293b0ecb6ec8a5368143a7266b4eb789cfb9d30e8e
4
+ data.tar.gz: c4de7c524b1e42e06aa44fa87bcbd8fa3aeb26b0c4d5696613b0d3c2983aa22f
5
5
  SHA512:
6
- metadata.gz: 5553f52dda5f8f60ab29f1186cf1d1b7af5430a778338850e6af5dbce4b0997b6ae72b5600f98619de1111c2803e9a7e5a1cc74ef08ed591598541f8b3f77ea2
7
- data.tar.gz: 4df1c6890f17595eae40d247a2af6ad9a3e054b037065015076256dadae54f5ec9329ed4e0d8f6d1d632cf1ffa584c44db6277fb8f152880e81e534fad2262a7
6
+ metadata.gz: 755bd921f59c02db3ee8c6f4806983d0923a6af119206c2dcfce9be2d2214584f9a19b788332daca4f205182cd9460da10fa84f365264e79d8827526d4c3d100
7
+ data.tar.gz: 7b44323c8202c123b1f8bed6f012ab32c06de35019a0a9e4d8d516e1c0bb0228f2b089082b1d69b742c6751fd810fe58046f32ad1932ca3ad84259d1582ac883
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'activerecord-mysql2-adapter-patch'
5
- s.version = '0.1.0'
5
+ s.version = '5.1.4'
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'
@@ -1,20 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_record'
4
- require 'active_record/connection_adapters/mysql2_adapter'
4
+ require 'active_record/connection_adapters/abstract_mysql_adapter'
5
5
 
6
- class ActiveRecord::ConnectionAdapters::Mysql2Adapter
7
- def each_hash(result) # :nodoc:
8
- if block_given?
9
- result.each(as: :hash, symbolize_keys: true) do |row|
10
- if row[:Type] == 'datetime' && row[:Extra] != ''
11
- row[:Default] += ' ' + row[:Extra]
12
- row[:Extra] = ''
13
- end
14
- yield row
15
- end
6
+ class ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
7
+ def new_column_from_field(table_name, field) # :nodoc:
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"
11
+ default_function += ' ' + field[:Extra] if field[:Extra] != ''
16
12
  else
17
- to_enum(:each_hash, result)
13
+ default, default_function = field[:Default], nil
18
14
  end
15
+ new_column(field[:Field], default, type_metadata, field[:Null] == "YES", table_name, default_function, field[:Collation], comment: field[:Comment].presence)
19
16
  end
20
17
  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: 0.1.0
4
+ version: 5.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch