-
Notifications
You must be signed in to change notification settings - Fork 0
[HOLD] [FCM-8671] Rails 8 update #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f547cd2
46cdaa4
c01f473
5c56db4
592c057
03d89f9
a74a8ea
1ee36f1
957826d
1172e9c
ef12e69
3fc20e8
9200eb4
302a807
498a584
40e2b27
f77fc1e
2164bf3
148a2cc
c9ad377
246e6c9
6f9bfc3
ebb1d76
6253f67
f86162e
ced3ea0
c5f3319
986cd98
ebe8c81
073022e
3abc8c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| source "https://rubygems.org" | ||
|
|
||
| gemspec path: ".." | ||
|
|
||
| gem "activerecord", github: "rails/rails", branch: "8-0-stable" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| source "https://rubygems.org" | ||
|
|
||
| gemspec path: ".." | ||
|
|
||
| gem "activerecord", github: "rails/rails", branch: "8-1-stable" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,37 @@ | ||
| module PolymorphicIntegerType | ||
| module BelongsToPolymorphicAssociationExtension | ||
| private | ||
| module ActiveRecord | ||
| module Associations | ||
| class BelongsToPolymorphicAssociation < BelongsToAssociation | ||
| private | ||
|
|
||
| if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("6.1") | ||
| def replace_keys(record) | ||
| super | ||
|
|
||
| if reflection.options[:integer_type] || reflection.options[:polymorphic].is_a?(Hash) | ||
| owner[reflection.foreign_type] = record.class.base_class unless record.nil? | ||
| end | ||
| end | ||
| else | ||
| def replace_keys(record, force: false) | ||
| super | ||
| return if record.nil? | ||
|
|
||
| if reflection.options[:integer_type] || reflection.options[:polymorphic].is_a?(Hash) | ||
| owner[reflection.foreign_type] = record.class.base_class unless record.nil? | ||
| end | ||
| # FCM fork delta -- RE-APPLY after any upstream sync! | ||
| # | ||
| # This gem *reopens* (does not prepend) `BelongsToPolymorphicAssociation`, | ||
| # so the `super` above is BelongsToAssociation#replace_keys, which sets | ||
| # the foreign key but NOT the polymorphic type, so this method is | ||
| # responsible for the `_type`. | ||
| # | ||
| # Upstream sets it unconditionally to the target's `base_class`, which | ||
| # clobbers a model's custom `polymorphic_name` on plain `polymorphic: true` | ||
| # associations. | ||
| # | ||
| # The rma app relies on custom `polymorphic_name` (e.g. | ||
| # Enrollment => 'Patient::Segment'), so use `base_class` ONLY for this | ||
| # gem's integer-type associations (detected via the generated | ||
| # `<foreign_type>_mapping` class method) and fall back to Rails' | ||
| # `polymorphic_name` for plain polymorphic associations. | ||
| # | ||
| # Regression is tested in spec/fcm_polymorphic_name_guard_spec.rb. | ||
| owner[reflection.foreign_type] = | ||
| if owner.class.respond_to?("#{reflection.foreign_type}_mapping") | ||
| record.class.base_class | ||
| else | ||
| record.class.polymorphic_name | ||
| end | ||
|
Comment on lines
+28
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice, much simpler than the multi-file change that we had before to fix the STI inheritance issue! Checking |
||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| ActiveRecord::Associations::BelongsToPolymorphicAssociation.prepend(PolymorphicIntegerType::BelongsToPolymorphicAssociationExtension) | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module PolymorphicIntegerType | ||
| VERSION = "3.3.0" | ||
| VERSION = '3.5.0' | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,30 @@ | ||
| # coding: utf-8 | ||
| lib = File.expand_path('../lib', __FILE__) | ||
| # frozen_string_literal: true | ||
|
|
||
| lib = File.expand_path('lib', __dir__) | ||
| $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
| require 'polymorphic_integer_type/version' | ||
|
|
||
| Gem::Specification.new do |spec| | ||
| spec.name = "polymorphic_integer_type" | ||
| spec.name = 'polymorphic_integer_type' | ||
| spec.version = PolymorphicIntegerType::VERSION | ||
| spec.authors = ["Kyle d'Oliveira"] | ||
| spec.email = ["kyle@goclio.com"] | ||
| spec.description = %q{Allows the *_type field in the DB to be an integer rather than a string} | ||
| spec.summary = %q{Use integers rather than strings for the _type field} | ||
| spec.homepage = "" | ||
| spec.license = "MIT" | ||
| spec.authors = ['Kyle d\'Oliveira'] | ||
| spec.email = ['kyle@goclio.com'] | ||
| spec.description = 'Allows the *_type field in the DB to be an integer rather than a string' | ||
| spec.summary = 'Use integers rather than strings for the _type field' | ||
| spec.homepage = '' | ||
| spec.license = 'MIT' | ||
|
|
||
| spec.required_ruby_version = '>= 3.0' | ||
|
|
||
| spec.files = `git ls-files -- . ':!.github/'`.split($/) | ||
| spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
| spec.require_paths = ["lib"] | ||
| spec.require_paths = ['lib'] | ||
|
|
||
| spec.add_dependency "activerecord", "< 8" | ||
| spec.add_development_dependency "bundler" | ||
| spec.add_development_dependency "rake" | ||
| spec.add_development_dependency "rspec" | ||
| spec.add_development_dependency "sqlite3" | ||
| spec.add_development_dependency "pry-byebug" | ||
| spec.add_dependency 'activerecord', '< 9.0' | ||
| spec.add_development_dependency 'bundler' | ||
| spec.add_development_dependency 'pry-byebug' | ||
| spec.add_development_dependency 'rake' | ||
| spec.add_development_dependency 'rspec' | ||
| spec.add_development_dependency 'sqlite3' | ||
| end |
Uh oh!
There was an error while loading. Please reload this page.