-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Only set duration attribute to interval on Rails 6.1 #1412
Only set duration attribute to interval on Rails 6.1 #1412
Conversation
This causes ActiveRecord::ConnectionNotEstablished issues with Tapioca
This seems fine, the line is only relevant on 6.1 anyways like you said. I don't use tapioca myself but I was curios and added it to one of my apps and encounter the same behaviour as you. I'm a bit surprised that it worked on 4.0.1 without the database being up at all. I guess I'm surprised by rails needing an active connection for this call at all. For that reason alone this seems like a good change to do. |
Thank you both. This makes sense to me:
I guess the alternative would be to remove the # this load hook doesn't exist yet
ActiveSupport.on_load(:good_job_execution) do
attribute :duration, :interval
end |
It should be set on 6.1 in my opinion. The moment you want to do more with the Alternativly, wait for someone to actually complain. I only changed this because I noticed the deprecation in CI output. |
Those are good points 🤔 I feel like the balance here is like: (right now right now) a big annoyance versus breakage. And so if I think of like elevating a new user who is considering adopting GoodJob, I sort of imagine their appetite for debugging is lower than someone who is already using GoodJob 😦 I think I'm leaning toward just removing the |
I'll push that change to this branch, and land #1414 at the same time. |
Welp, I guess I can change my mind in 2 minutes. Yes, let's do this as is and I'll wait to see if anyone opens an issue about Tapioca incompatibility. |
@bdewater-thatch found a test (rails/rails#41302) which expects that this doesn't require a connection. I tried making a repro for this, thought perhaps it's pg interval specific but no luck, the test just passes: # frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
# gem "rails", github: "rails/rails", branch: "main"
gem "rails", "7.1"
gem "pg"
end
require "active_record/railtie"
require "minitest/autorun"
require "logger"
class TestApp < Rails::Application
config.load_defaults 7.1
config.eager_load = false
config.root = __dir__
config.logger = Logger.new($stdout)
Rails.logger = config.logger
end
ENV["DATABASE_URL"] = "postgresql://localhost:5432/foo"
Rails.application.initialize!
require "active_support/testing/method_call_assertions"
class BugTest < ActiveSupport::TestCase
include ActiveSupport::Testing::MethodCallAssertions
def test_not_called
assert_not_called(ActiveRecord::Base, :connection) do
Class.new(ActiveRecord::Base) do
attribute :foo, :interval
end
end
end
end |
Thanks @bensheldon!
Tapioca follows Rails' support policy. With 6.1 being EOL Tapioca support for it is on a best effort basis - see Shopify/tapioca#1913 (comment) - so unless someone comes up with an elegant fix to make it all work I think this the current state is fine. |
@Earlopain I found that PR too, thanks for trying to create a repro script. FWIW we do have some |
Yeah, I guess it could be because of an engine. I'd have to do some more testing, at least I've hit the issue myself. If I manage to report upstream I'll link it here. |
Should have just started with a fresh bug report template instead of mangling the last one I had still around. Here it is: rails/rails#52311 |
This causes
ActiveRecord::ConnectionNotEstablished
issues in 4.0.2 with Tapioca, this works around the problem by not setting it if not needed. I think it's a bug in Tapioca so I opened Shopify/tapioca#1950 but figured this might be a useful workaround in the meantime.This line was originally shipped in #1408, 4.0.1 does not causes issues for me.