Skip to content

Commit

Permalink
Patch #schema_cache on AR directly to make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
kratob committed Aug 13, 2024
1 parent 4ee4934 commit 261d79b
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lib/active_type/no_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,38 @@ def initialize(*)

end

class DummyConnectionPool < ActiveRecord::ConnectionAdapters::NullPool

attr_reader :schema_cache

def initialize(*)
super
@schema_cache = DummySchemaCache.new
@connection = DummyConnection.new(nil)
end

def with_connection(**)
yield(@connection)
end

def active_connection
@connection
end

end

module ClassMethods

def connection
@connection ||= DummyConnection.new(nil)
end

if ActiveRecord::Base.respond_to?(:connection_pool)
def connection_pool
@connection_pool ||= DummyConnectionPool.new
end
end

def destroy(*)
new
end
Expand All @@ -147,7 +173,6 @@ def find_by_sql(*)
def _query_by_sql(*)
[]
end

end

def destroy
Expand Down

0 comments on commit 261d79b

Please sign in to comment.