Skip to content

Commit

Permalink
Fix enum checker to handle enum breaking changes in Rails (#249)
Browse files Browse the repository at this point in the history
Co-authored-by: djezzzl <[email protected]>
  • Loading branch information
chaadow and djezzzl authored Feb 7, 2025
1 parent f7d0162 commit 66c51d5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ end
%w[5.2 6.0 6.1 7.0 7.1].each do |version|
appraise "ar_#{version.gsub('.', '_')}" do
remove_gem 'appraisal'
gem 'concurrent-ruby', '1.3.4'
gem 'activerecord', "~> #{version}.0"
gem 'sqlite3', '~> 1.3'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def enum_column_values # rubocop:disable Metrics/AbcSize
@enum_column_values ||=
if model.connection.enum_types.is_a?(Array)
_, values = model.connection.enum_types.find { |(enum, _)| enum == column.sql_type }
values.split(',').map(&:strip)
case values
when Array then values
else
values.split(',').map(&:strip)
end
else
# active_record-postgres_enum gem
model.connection.enum_types[column.sql_type.to_sym]
Expand Down
3 changes: 3 additions & 0 deletions rails6-example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gem 'database_consistency', path: '../', group: :development, require: false

# https://github.com/rails/rails/pull/54264
gem 'concurrent-ruby', '1.3.4'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.0'
# Use sqlite3 as the database for Active Record
Expand Down
5 changes: 5 additions & 0 deletions rails7-example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ gem 'database_consistency', path: '../', group: :development, require: false

gem "pg"

gem "logger"

# https://github.com/rails/rails/pull/54264
gem 'concurrent-ruby', '1.3.4'

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.6"

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'bundler/setup'
require 'logger'
require 'database_consistency'
require 'database_context'

Expand Down

0 comments on commit 66c51d5

Please sign in to comment.