activerecord-mysql-enum 0.1.2 → 0.1.3

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: 990d55ec62633ed4bc3da5770f0b37fe020b24681b689d2528defa237d3d3411
4
- data.tar.gz: 4500ece77eae411c0d4c51f1f7732258cb2c8e41ce8dc0bc7a0db56de0f491f6
3
+ metadata.gz: 55bc597834513644a73047cc9b1df7b853d2138a8bc9d72b2414ef85d38ccc44
4
+ data.tar.gz: fb8e43c87e03d2a5be842a18f3ad82bc01481f2200ee251aca8c20bdf972a4bc
5
5
  SHA512:
6
- metadata.gz: e993d90711a95befe09afff1f556e7f3a533cd2668a13164e69bb078601735f621bef907e373415280e6fb3a343b561a4ed479c70bdf3d95ce937ca86029654d
7
- data.tar.gz: a1599a97a54c13f69f12f2c02be06b004d9b613ebe8913e3044eaa7b62a3b2b133c27231d4918508bd9af34388d31a0df8d49c01228444eeda68506302a400f3
6
+ metadata.gz: 0d33416541bb774bc5ca50ee8abf09303a40492fe6664c1d574d466d7a202c809e45f32753e4a98f4155507dd3395e1bb46465576850a1d50fd950ee63ea5274
7
+ data.tar.gz: 922721961100bac1179f6f1aef232f7258834e516b73be14845b70fbf75f0d48243304beed0f0013d1f9d0526e76a8042864247a83fba0e3cef678ba661fec98
@@ -4,6 +4,10 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.1.3] - 2020-08-19
8
+ ### Changed
9
+ - refactor mysql adapter
10
+
7
11
  ## [0.1.2] - 2020-08-18
8
12
  ### Changed
9
13
  - fixed frozen string to reassign value instead of append
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-mysql-enum (0.1.2)
4
+ activerecord-mysql-enum (0.1.3)
5
5
  activerecord (>= 4.2, < 7)
6
6
 
7
7
  GEM
@@ -28,27 +28,35 @@ module ActiveRecord
28
28
  #
29
29
  # will generate enum('a', 'b', 'c') for :limit => [:a, :b, :c]
30
30
  if Rails::VERSION::MAJOR < 5
31
- def type_to_sql(type, limit = nil, precision = nil, scale = nil, unsigned = nil, **_options) # :nodoc:
31
+ def type_to_sql(type, limit = nil, precision = nil, scale = nil)
32
32
  if type.to_s == 'enum'
33
- native = native_database_types[type]
34
- column_type_sql = (native || {})[:name] || 'enum'
33
+ column_type_sql =
34
+ if (native_database_type = native_database_types[type])
35
+ native_database_type[:name]
36
+ else
37
+ 'enum'
38
+ end
35
39
 
36
- column_type_sql += "(#{limit.map { |v| quote(v) }.join(',')})"
40
+ quoted_values = limit.map { |v| quote(v) }.join(',')
37
41
 
38
- column_type_sql
42
+ "#{column_type_sql}(#{quoted_values})"
39
43
  else
40
- super(type, limit, precision, scale, unsigned)
44
+ super(type, limit, precision, scale)
41
45
  end
42
46
  end
43
47
  else
44
48
  def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **_options) # :nodoc:
45
49
  if type.to_s == 'enum'
46
- native = native_database_types[type]
47
- column_type_sql = (native || {})[:name] || 'enum'
50
+ column_type_sql =
51
+ if (native_database_type = native_database_types[type])
52
+ native_database_type[:name]
53
+ else
54
+ 'enum'
55
+ end
48
56
 
49
- column_type_sql += "(#{limit.map { |v| quote(v) }.join(',')})"
57
+ quoted_values = limit.map { |v| quote(v) }.join(',')
50
58
 
51
- column_type_sql
59
+ "#{column_type_sql}(#{quoted_values})"
52
60
  else
53
61
  super(type, limit: limit, precision: precision, scale: scale, unsigned: unsigned)
54
62
  end
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module Mysql
5
5
  module Enum
6
- VERSION = "0.1.2"
6
+ VERSION = "0.1.3"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysql-enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pohodnya
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-18 00:00:00.000000000 Z
12
+ date: 2020-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord