Greetings
I will limit this first post to fewer details; will provide just enough to give an idea about the problem, in case someone knows and is willing to help. Will provide more details if I get replies…
In Rails 6.1 I was able to query AWS Redshft cluster using ActiveRecord::Base, with adapter: “redshift” in the configuration parameters:
class myModel < ActiveRecord::Base
end
rs_params = {
adapter: "redshift",
host: "<hostid>.redshift.amazonaws.com",
port: "<port>",
database: "<dbname",
username: "<username>",
password: "<password>",
pool: 3,
timeout: 10
}
then…
myModel.establish_connection(rs_params)
That was it!
I think it was putting to use ‘activerecord6-redshift-adapter’ –
----- Now in Rails 7.2.2.1 everything appears broken. With activerecord7-redshift-adapter
For starters, I get:
/active_record/connection_adapters/redshift/schema_statements.rb:4:in ‘module:Redshift’: uninitialized constant ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation (NameError)
The reference path to the SchemaCreation appears wrong. I am finding “SchemaCreation” sitting in the above incorrectly stated grandparent relationsihp… So I do a patchy thing in my script, moving “SchemaCreation” up to subclass of ConnectionAdapters (already feeling jittery – this isn’t supposed to need patching… I may be simply entangling myself further). The “patch”:
class ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation < ActiveRecord::ConnectionAdapters::SchemaCreation
end
That breaks my (explicit) require of the adapter component ( require ‘active_record/connection_adapters/redshift_adapter.rb’ ), until I move the require AFTER the above “patch”
OK. The above gets me past the “SchemaCreation” not found error – it is now being found – or rather its duplicate class created to match the reference.
Now it starts telling me the adapter “redshift” doesn’t exit. I rummage through activerecord7-redshift-adapter-1.1.0/lib/active_record/connection_adapters/redshift_adapter.rb and am seeing the adapter name is now capitalized … (??? wtf):
class RedshiftAdapter < AbstractAdapter
ADAPTER_NAME = 'Redshift'.freeze
....
OK. I change ‘redshift’ to ‘Redshift’. I now get an error saying the ‘Redshift’ adapter is not registered…
I dig in the code and add registration manually:
ActiveRecord::ConnectionAdapters.register(
'Redshift',
'ActiveRecord::ConnectionAdapters::RedshiftAdapter',
'/active_record/connection_adapters/redshift_adapter.rb'
)
That gets me past the registration error.
Now I get
wrong number of arguments (given 1, expected 4)
/active_record/connection_adapters/redshift_adapter.rb:189:in ‘initialize’
Yeah… I see this in the above file:
def initialize(connection, logger, connection_parameters, config)
super(connection, logger, config)
@visitor = Arel::Visitors::PostgreSQL.new self
@prepared_statements = false
@connection_parameters = connection_parameters
top of the stack trace:
active_record/connection_adapters/redshift_adapter.rb:189:in 'initialize'
active_record/database_configurations/database_config.rb:26:in 'Class#new'
active_record/database_configurations/database_config.rb:26:in 'ActiveRecord::DatabaseConfigurations::DatabaseConfig#new_connection'
active_record/connection_adapters/abstract/connection_pool.rb:883:in 'ActiveRecord::ConnectionAdapters::ConnectionPool#new_connection'
I don’t know where to get the needed arguments
connection, logger, connection_parameters, config
and why they are not being inserted in the call … seems like a mismatch of functions… a mess.
I paused my hackery here, to post
What happened between the versions ? seems like we went from simple implementation to complexity, broken at that… or am I missing some new component that has been introduced? Can’t find documentation on this.
thanks.