activerecord-mysql-enum 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +13 -0
- data/.github/workflows/test.yml +6 -0
- data/Appraisals +13 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +3 -3
- data/README.md +9 -1
- data/enum_column.gemspec +1 -1
- data/gemfiles/rails_5.gemfile +2 -2
- data/gemfiles/rails_6.gemfile +2 -2
- data/gemfiles/rails_6_1.gemfile +16 -0
- data/gemfiles/rails_7_0.gemfile +16 -0
- data/lib/active_record/mysql/enum/enum_column_adapter.rb +0 -10
- data/lib/active_record/mysql/enum/mysql_adapter.rb +18 -7
- data/lib/active_record/mysql/enum/schema_definitions.rb +1 -1
- data/lib/active_record/mysql/enum/version.rb +1 -1
- data/lib/active_record/mysql/enum.rb +16 -10
- metadata +8 -6
- data/.dependabot/config.yml +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a31298ed5c99c46cc43f7f7505037b01aae924b9ee711327d1f48c23d00439d
|
4
|
+
data.tar.gz: a2c86f1f9bdb2e0407f7aec6c94cc187020bac9b14e10568a83b0fd1c9103895
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9e47756714d2672b42d981893d8e43b1b9c1b85c7d4ede2c932b3741fc13250c47ab387fcc21beee684bd68c7d8a64c69c7afa2ed1e41f92e11e1aac42623c0
|
7
|
+
data.tar.gz: 6fff0d2528b54ab4e683b1bca7e754667c2b2695098ff9ec4db1e6a737e5103b09d93851229af0a1cfdc757f48d4ecdbe3a6075f6c595991c2aa01d6e9a2b5d3
|
@@ -0,0 +1,13 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: daily
|
7
|
+
time: "22:00"
|
8
|
+
timezone: PST8PDT
|
9
|
+
open-pull-requests-limit: 99
|
10
|
+
versioning-strategy: lockfile-only
|
11
|
+
commit-message:
|
12
|
+
prefix: No-Jira
|
13
|
+
include: scope
|
data/.github/workflows/test.yml
CHANGED
@@ -24,6 +24,8 @@ jobs:
|
|
24
24
|
- Gemfile
|
25
25
|
- gemfiles/rails_5.gemfile
|
26
26
|
- gemfiles/rails_6.gemfile
|
27
|
+
- gemfiles/rails_6_1.gemfile
|
28
|
+
- gemfiles/rails_7_0.gemfile
|
27
29
|
exclude:
|
28
30
|
- ruby: '3.0'
|
29
31
|
gemfile: Gemfile
|
@@ -33,6 +35,10 @@ jobs:
|
|
33
35
|
gemfile: gemfiles/rails_5.gemfile
|
34
36
|
- ruby: 3.1
|
35
37
|
gemfile: gemfiles/rails_5.gemfile
|
38
|
+
- ruby: 2.5.8
|
39
|
+
gemfile: gemfiles/rails_7_0.gemfile
|
40
|
+
- ruby: 2.6.5
|
41
|
+
gemfile: gemfiles/rails_7_0.gemfile
|
36
42
|
env:
|
37
43
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
38
44
|
DATABASE_MYSQL_HOST: 127.0.0.1
|
data/Appraisals
CHANGED
@@ -8,4 +8,17 @@ end
|
|
8
8
|
appraise 'rails-6' do
|
9
9
|
gem 'rails', '~> 6.0.0'
|
10
10
|
gem 'mysql2', '~> 0.5'
|
11
|
+
gem "net-smtp", require: false
|
12
|
+
end
|
13
|
+
|
14
|
+
appraise 'rails-6-1' do
|
15
|
+
gem 'rails', '~> 6.1.0'
|
16
|
+
gem 'mysql2', '~> 0.5'
|
17
|
+
gem "net-smtp", require: false
|
18
|
+
end
|
19
|
+
|
20
|
+
appraise 'rails-7-0' do
|
21
|
+
gem 'rails', '~> 7.0.0'
|
22
|
+
gem 'mysql2', '~> 0.5'
|
23
|
+
gem "net-smtp", require: false
|
11
24
|
end
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ 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
|
+
## [2.3.0] - 2022-09-14
|
8
|
+
### Added
|
9
|
+
- Added the ability for non-rails applications to use the gem by using `initialize!` in the application's bootstrapping code after ActiveRecord has been configured.
|
10
|
+
|
11
|
+
## [2.2.0] - 2022-07-18
|
12
|
+
### Added
|
13
|
+
- Added support for Rails 6.1 and 7.0
|
14
|
+
|
7
15
|
## [2.1.0] - 2022-04-11
|
8
16
|
### Added
|
9
17
|
- Added ruby 3 support
|
@@ -56,6 +64,8 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
56
64
|
### Changed
|
57
65
|
- Renamed the gem from `enum_column3` to `activerecord-mysql-enum`
|
58
66
|
|
67
|
+
[2.3.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v2.2.0...v2.3.0
|
68
|
+
[2.2.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v2.1.0...v2.2.0
|
59
69
|
[2.1.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v2.0.0...v2.1.0
|
60
70
|
[2.0.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v1.0.0...v2.0.0
|
61
71
|
[1.0.0]: https://github.com/Invoca/activerecord-mysql-enum/compare/v0.1.4...v1.0.0
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activerecord-mysql-enum (2.
|
5
|
-
activerecord (>= 5.2, < 7)
|
4
|
+
activerecord-mysql-enum (2.3.0)
|
5
|
+
activerecord (>= 5.2, < 7.1)
|
6
6
|
mysql2 (>= 0.4.5, < 0.6)
|
7
7
|
|
8
8
|
GEM
|
@@ -83,7 +83,7 @@ GEM
|
|
83
83
|
mini_mime (1.1.0)
|
84
84
|
mini_portile2 (2.6.1)
|
85
85
|
minitest (5.14.4)
|
86
|
-
mysql2 (0.5.
|
86
|
+
mysql2 (0.5.4)
|
87
87
|
nio4r (2.5.8)
|
88
88
|
nokogiri (1.12.2)
|
89
89
|
mini_portile2 (~> 2.6.1)
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ which was itself a fork of a fork of Nick Pohodnya's original gem for
|
|
7
7
|
Rails 3, [enum_column3](https://github.com/electronick/enum_column).
|
8
8
|
|
9
9
|
## Support
|
10
|
-
Currently this is tested with
|
10
|
+
Currently this is tested with ActiveRecord version 5.2, 6.0, 6.1, and 7.0.
|
11
11
|
|
12
12
|
**Supported adapters:**
|
13
13
|
- mysql2
|
@@ -18,6 +18,14 @@ In your `Gemfile` add the following snippet
|
|
18
18
|
gem 'activerecord-mysql-enum', '~> 1.0', require: 'active_record/mysql/enum'
|
19
19
|
```
|
20
20
|
|
21
|
+
### Non-Rails Application
|
22
|
+
In order to initialize the extension in non-Rails applications, you must add the following line
|
23
|
+
to your application's bootstrapping code after ActiveRecord has been initialized.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
ActiveRecord::Mysql::Enum.initialize!
|
27
|
+
```
|
28
|
+
|
21
29
|
## Usage
|
22
30
|
### Schema Definitions
|
23
31
|
When defining an enum in your schema, specify the constraint as a limit:
|
data/enum_column.gemspec
CHANGED
data/gemfiles/rails_5.gemfile
CHANGED
data/gemfiles/rails_6.gemfile
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "coveralls", require: false
|
7
|
+
gem "pry"
|
8
|
+
gem "pry-byebug"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rails", "~> 6.1.0"
|
11
|
+
gem "rspec", "~> 3.11"
|
12
|
+
gem "rspec-rails", "~> 5.0"
|
13
|
+
gem "mysql2", "~> 0.5"
|
14
|
+
gem "net-smtp", require: false
|
15
|
+
|
16
|
+
gemspec path: "../"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal"
|
6
|
+
gem "coveralls", require: false
|
7
|
+
gem "pry"
|
8
|
+
gem "pry-byebug"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rails", "~> 7.0.0"
|
11
|
+
gem "rspec", "~> 3.11"
|
12
|
+
gem "rspec-rails", "~> 5.0"
|
13
|
+
gem "mysql2", "~> 0.5"
|
14
|
+
gem "net-smtp", require: false
|
15
|
+
|
16
|
+
gemspec path: "../"
|
@@ -22,16 +22,6 @@ module ActiveRecord
|
|
22
22
|
ActiveRecordColumnWithEnums = Enum.mysql_column_adapter
|
23
23
|
|
24
24
|
module EnumColumnAdapter
|
25
|
-
def initialize(*args, **kwargs, &block)
|
26
|
-
super
|
27
|
-
|
28
|
-
if type == :enum
|
29
|
-
@default = if @default.present?
|
30
|
-
@default.to_sym
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
25
|
# Convert to a symbol.
|
36
26
|
def type_cast_from_database(value)
|
37
27
|
if type == :enum
|
@@ -10,6 +10,13 @@ module ActiveRecord
|
|
10
10
|
|
11
11
|
ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
12
12
|
end
|
13
|
+
|
14
|
+
def register_enum_with_type_mapping(m)
|
15
|
+
m.register_type(/enum/i) do |sql_type|
|
16
|
+
limit = sql_type.sub(/^enum\('(.+)'\)/i, '\1').split("','").map { |v| v.to_sym }
|
17
|
+
ActiveRecord::Type::Enum.new(limit: limit)
|
18
|
+
end
|
19
|
+
end
|
13
20
|
end
|
14
21
|
|
15
22
|
ActiveRecordMysqlAdapter = Enum.mysql_adapter
|
@@ -45,20 +52,24 @@ module ActiveRecord
|
|
45
52
|
end
|
46
53
|
end
|
47
54
|
|
55
|
+
if Gem::Version.new(ActiveRecord.version) < Gem::Version.new('7.0')
|
56
|
+
private
|
48
57
|
|
49
|
-
|
50
|
-
|
51
|
-
def initialize_type_map(m = type_map)
|
52
|
-
super
|
58
|
+
def initialize_type_map(m = type_map)
|
59
|
+
super
|
53
60
|
|
54
|
-
|
55
|
-
limit = sql_type.sub(/^enum\('(.+)'\)/i, '\1').split("','").map { |v| v.to_sym }
|
56
|
-
ActiveRecord::Type::Enum.new(limit: limit)
|
61
|
+
Enum.register_enum_with_type_mapping(m)
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
61
66
|
ActiveRecordMysqlAdapter.prepend ActiveRecord::Mysql::Enum::MysqlAdapter
|
67
|
+
|
68
|
+
unless Gem::Version.new(ActiveRecord.version) < Gem::Version.new('7.0')
|
69
|
+
[ActiveRecordMysqlAdapter::TYPE_MAP, ActiveRecordMysqlAdapter::TYPE_MAP_WITH_BOOLEAN].each do |m|
|
70
|
+
Enum.register_enum_with_type_mapping(m)
|
71
|
+
end
|
72
|
+
end
|
62
73
|
end
|
63
74
|
end
|
64
75
|
end
|
@@ -1,18 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
module
|
5
|
-
module
|
6
|
-
|
3
|
+
module ActiveRecord
|
4
|
+
module Mysql
|
5
|
+
module Enum
|
6
|
+
class << self
|
7
|
+
def initialize!
|
8
|
+
require 'active_record/mysql/enum/mysql_adapter'
|
9
|
+
require 'active_record/mysql/enum/enum_type'
|
10
|
+
require 'active_record/mysql/enum/enum_column_adapter'
|
11
|
+
require 'active_record/mysql/enum/schema_definitions'
|
12
|
+
require 'active_record/mysql/enum/quoting'
|
13
|
+
require 'active_record/mysql/enum/validations'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
if defined?(::Rails::Railtie)
|
7
18
|
class Railtie < Rails::Railtie
|
8
19
|
initializer 'active_record-mysql-enum.initialize', :after => 'active_record.initialize_database' do |app|
|
9
20
|
ActiveSupport.on_load :active_record do
|
10
|
-
|
11
|
-
require 'active_record/mysql/enum/enum_type'
|
12
|
-
require 'active_record/mysql/enum/enum_column_adapter'
|
13
|
-
require 'active_record/mysql/enum/schema_definitions'
|
14
|
-
require 'active_record/mysql/enum/quoting'
|
15
|
-
require 'active_record/mysql/enum/validations'
|
21
|
+
ActiveRecord::Mysql::Enum.initialize!
|
16
22
|
end
|
17
23
|
end
|
18
24
|
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: 2.
|
4
|
+
version: 2.3.0
|
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: 2022-
|
12
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
version: '5.2'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '7'
|
23
|
+
version: '7.1'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: '5.2'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '7'
|
33
|
+
version: '7.1'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: mysql2
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ executables: []
|
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
|
-
- ".dependabot
|
61
|
+
- ".github/dependabot.yml"
|
62
62
|
- ".github/workflows/gem_release.yml"
|
63
63
|
- ".github/workflows/test.yml"
|
64
64
|
- ".gitignore"
|
@@ -76,6 +76,8 @@ files:
|
|
76
76
|
- gemfiles/.bundle/config
|
77
77
|
- gemfiles/rails_5.gemfile
|
78
78
|
- gemfiles/rails_6.gemfile
|
79
|
+
- gemfiles/rails_6_1.gemfile
|
80
|
+
- gemfiles/rails_7_0.gemfile
|
79
81
|
- init.rb
|
80
82
|
- lib/active_record/mysql/enum.rb
|
81
83
|
- lib/active_record/mysql/enum/enum_column_adapter.rb
|
@@ -107,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
109
|
- !ruby/object:Gem::Version
|
108
110
|
version: '0'
|
109
111
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
112
|
+
rubygems_version: 3.1.6
|
111
113
|
signing_key:
|
112
114
|
specification_version: 4
|
113
115
|
summary: Enable enum type for the MySQL Adapter in ActiveRecord
|