hengfengli
Repos
51
Followers
66
Following
122

Events

chore: update the code owners.
Created at 3 weeks ago

chore: update the code owners.

Created at 3 weeks ago
hengfengli create branch update-owners
Created at 3 weeks ago

docs: update README.md to remove unnecessary git link (#130)

Fix another adapter transaction was broken when using multiple adapter (#129)

Summary

ActiveRecord supports the use of multiple database adapters and class-based connection management. However, due to the effect that the spanner adapter is patching ActiveRecord::Base, transactions for other adapters will fail.

Step to reproduce

Case. 1

require "bundler/inline"

gemfile do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem 'activerecord', '6.1.4'
  gem 'activerecord-spanner-adapter'
  gem 'sqlite3'
end

require "active_record"
require "minitest/autorun"

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")

class Item < ActiveRecord::Base
end

ActiveRecord::Schema.define do
  create_table :items, force: true do |t|
  end
end

require "active_record/connection_adapters/spanner_adapter"

class BugTest < Minitest::Test
  def test_connection
    Item.create
  end

  def test_connection2
    Item.create!
  end
end

#   1) Error:
# BugTest#test_connection:
# ActiveRecord::TransactionIsolationError: SQLite3 only supports the `read_uncommitted` transaction isolation level
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/sqlite3/database_statements.rb:80:in `begin_isolated_db_transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:205:in `materialize!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:285:in `block (2 levels) in materialize_transactions'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:285:in `each'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:285:in `block in materialize_transactions'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:282:in `materialize_transactions'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:328:in `materialize_transactions'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/sqlite3/database_statements.rb:41:in `exec_query'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/sqlite3_adapter.rb:345:in `table_structure'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in `columns'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:112:in `block in columns'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:111:in `fetch'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:111:in `columns'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:120:in `block in columns_hash'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:119:in `fetch'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:119:in `columns_hash'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:553:in `load_schema!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/attributes.rb:250:in `load_schema!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:539:in `block in load_schema'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:536:in `synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:536:in `load_schema'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:402:in `attribute_types'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/attribute_methods.rb:187:in `_has_attribute?'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/inheritance.rb:57:in `new'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/persistence.rb:37:in `create'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-spanner-adapter-0.6.0/lib/activerecord_spanner_adapter/base.rb:22:in `block in create'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/transactions.rb:209:in `transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-spanner-adapter-0.6.0/lib/activerecord_spanner_adapter/base.rb:21:in `create'
#     test1.rb:30:in `test_connection'
# 
#   2) Error:
# BugTest#test_connection2:
# NoMethodError: undefined method `current_spanner_transaction' for #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x00007fc64519f380 @transaction_manager=#<ActiveRecord::ConnectionAdapters::TransactionManager:0x00007fc645163a38 @stack=[], @connection=#<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x00007fc64519f380 ...>, @has_unmaterialized_transactions=true, @materializing_transactions=false, @lazy_transactions_enabled=true>, @query_cache={}, @query_cache_enabled=false, @connection=#<SQLite3::Database:0x00007fc64519fb50 @tracefunc=nil, @authorizer=nil, @encoding=#<Encoding:UTF-8>, @busy_handler=nil, @collations={}, @functions={}, @results_as_hash=true, @type_translation=nil, @type_translator=#<Proc:0x00007fc64190cf68 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:722 (lambda)>, @readonly=false>, @owner=#<Thread:0x00007fc64207bc40 run>, @instrumenter=#<ActiveSupport::Notifications::Instrumenter:0x00007fc6459658a8 @id="d640ccfb24114917261a", @notifier=#<ActiveSupport::Notifications::Fanout:0x00007fc6451a6a90 @string_subscribers={"backtrace_cleaner=.active_record"=>[#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dd7a0 @pattern="backtrace_cleaner=.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 @queue_key="ActiveRecord::LogSubscriber-2880", @patterns={"backtrace_cleaner=.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dd7a0 ...>, "backtrace_cleaner.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dcb20 @pattern="backtrace_cleaner.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "sql.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107cb8 @pattern="sql.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "backtrace_cleaner?.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107998 @pattern="backtrace_cleaner?.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "strict_loading_violation.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107880 @pattern="strict_loading_violation.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>}>, @can_publish=false>], "backtrace_cleaner.active_record"=>[#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dcb20 @pattern="backtrace_cleaner.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 @queue_key="ActiveRecord::LogSubscriber-2880", @patterns={"backtrace_cleaner=.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dd7a0 @pattern="backtrace_cleaner=.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "backtrace_cleaner.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dcb20 ...>, "sql.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107cb8 @pattern="sql.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "backtrace_cleaner?.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107998 @pattern="backtrace_cleaner?.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "strict_loading_violation.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107880 @pattern="strict_loading_violation.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>}>, @can_publish=false>], "sql.active_record"=>[#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107cb8 @pattern="sql.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 @queue_key="ActiveRecord::LogSubscriber-2880", @patterns={"backtrace_cleaner=.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dd7a0 @pattern="backtrace_cleaner=.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "backtrace_cleaner.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dcb20 @pattern="backtrace_cleaner.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "sql.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107cb8 ...>, "backtrace_cleaner?.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107998 @pattern="backtrace_cleaner?.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "strict_loading_violation.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107880 @pattern="strict_loading_violation.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>}>, @can_publish=false>, #<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc645171520 @pattern="sql.active_record", @delegate=#<ActiveRecord::ExplainSubscriber:0x00007fc645171b10>, @can_publish=false>], "backtrace_cleaner?.active_record"=>[#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107998 @pattern="backtrace_cleaner?.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 @queue_key="ActiveRecord::LogSubscriber-2880", @patterns={"backtrace_cleaner=.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dd7a0 @pattern="backtrace_cleaner=.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "backtrace_cleaner.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dcb20 @pattern="backtrace_cleaner.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "sql.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107cb8 @pattern="sql.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "backtrace_cleaner?.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107998 ...>, "strict_loading_violation.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107880 @pattern="strict_loading_violation.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>}>, @can_publish=false>], "strict_loading_violation.active_record"=>[#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107880 @pattern="strict_loading_violation.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 @queue_key="ActiveRecord::LogSubscriber-2880", @patterns={"backtrace_cleaner=.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dd7a0 @pattern="backtrace_cleaner=.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "backtrace_cleaner.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc6458dcb20 @pattern="backtrace_cleaner.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "sql.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107cb8 @pattern="sql.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "backtrace_cleaner?.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107998 @pattern="backtrace_cleaner?.active_record", @delegate=#<ActiveRecord::LogSubscriber:0x00007fc6458dea88 ...>, @can_publish=false>, "strict_loading_violation.active_record"=>#<ActiveSupport::Notifications::Fanout::Subscribers::Evented:0x00007fc642107880 ...>}>, @can_publish=false>], "!connection.active_record"=>[], "instantiation.active_record"=>[]}, @other_subscribers=[], @listeners_for=#<Concurrent::Map:0x00007fc6451a6950 entries=3 default_proc=nil>, @_mutex=#<Thread::Mutex:0x00007fc6451a6798>>>, @logger=nil, @config={:adapter=>"sqlite3", :database=>":memory:"}, @pool=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00007fc64595fe08 @mon_data=#<Monitor:0x00007fc64595f110>, @mon_data_owner_object_id=2960, @query_cache_enabled=#<Concurrent::Map:0x00007fc64595e8a0 entries=0 default_proc=#<Proc:0x00007fc64595df90 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/query_cache.rb:32>>, @pool_config=#<ActiveRecord::ConnectionAdapters::PoolConfig:0x00007fc6459660f0 @_mutex=#<Thread::Mutex:0x00007fc645965fb0>, @connection_klass=ActiveRecord::Base, @db_config=#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fc6459a4c60 @env_name="default_env", @name="primary", @configuration_hash={:adapter=>"sqlite3", :database=>":memory:"}>, @pool=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00007fc64595fe08 ...>, @schema_cache=#<ActiveRecord::ConnectionAdapters::SchemaCache:0x00007fc6451d64e8 @connection=#<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x00007fc64519f380 ...>, @columns={"ar_internal_metadata"=>[#<ActiveRecord::ConnectionAdapters::Column:0x00007fc6419dc588 @name="key", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc645967450 @sql_type="varchar", @type=:string, @limit=nil, @precision=nil, @scale=nil>, @null=false, @default=nil, @default_function=nil, @collation=nil, @comment=nil>, #<ActiveRecord::ConnectionAdapters::Column:0x00007fc6459e4ae0 @name="value", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc645967450 @sql_type="varchar", @type=:string, @limit=nil, @precision=nil, @scale=nil>, @null=true, @default=nil, @default_function=nil, @collation=nil, @comment=nil>, #<ActiveRecord::ConnectionAdapters::Column:0x00007fc6459dee10 @name="created_at", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc6459defc8 @sql_type="datetime(6)", @type=:datetime, @limit=nil, @precision=6, @scale=nil>, @null=false, @default=nil, @default_function=nil, @collation=nil, @comment=nil>, #<ActiveRecord::ConnectionAdapters::Column:0x00007fc6459de960 @name="updated_at", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc6459defc8 @sql_type="datetime(6)", @type=:datetime, @limit=nil, @precision=6, @scale=nil>, @null=false, @default=nil, @default_function=nil, @collation=nil, @comment=nil>]}, @columns_hash={"ar_internal_metadata"=>{"key"=>#<ActiveRecord::ConnectionAdapters::Column:0x00007fc6419dc588 @name="key", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc645967450 @sql_type="varchar", @type=:string, @limit=nil, @precision=nil, @scale=nil>, @null=false, @default=nil, @default_function=nil, @collation=nil, @comment=nil>, "value"=>#<ActiveRecord::ConnectionAdapters::Column:0x00007fc6459e4ae0 @name="value", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc645967450 @sql_type="varchar", @type=:string, @limit=nil, @precision=nil, @scale=nil>, @null=true, @default=nil, @default_function=nil, @collation=nil, @comment=nil>, "created_at"=>#<ActiveRecord::ConnectionAdapters::Column:0x00007fc6459dee10 @name="created_at", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc6459defc8 @sql_type="datetime(6)", @type=:datetime, @limit=nil, @precision=6, @scale=nil>, @null=false, @default=nil, @default_function=nil, @collation=nil, @comment=nil>, "updated_at"=>#<ActiveRecord::ConnectionAdapters::Column:0x00007fc6459de960 @name="updated_at", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc6459defc8 @sql_type="datetime(6)", @type=:datetime, @limit=nil, @precision=6, @scale=nil>, @null=false, @default=nil, @default_function=nil, @collation=nil, @comment=nil>}}, @primary_keys={}, @data_sources={"items"=>true, "ar_internal_metadata"=>true}, @indexes={}>>, @db_config=#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fc6459a4c60 @env_name="default_env", @name="primary", @configuration_hash={:adapter=>"sqlite3", :database=>":memory:"}>, @connection_klass=ActiveRecord::Base, @checkout_timeout=5.0, @idle_timeout=300.0, @size=5, @thread_cached_conns=#<Concurrent::Map:0x00007fc64595c5c8 entries=1 default_proc=nil>, @connections=[#<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x00007fc64519f380 ...>], @automatic_reconnect=true, @now_connecting=0, @threads_blocking_new_connections=0, @available=#<ActiveRecord::ConnectionAdapters::ConnectionPool::ConnectionLeasingQueue:0x00007fc645957aa0 @lock=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00007fc64595fe08 ...>, @cond=#<MonitorMixin::ConditionVariable:0x00007fc645957910 @monitor=#<Monitor:0x00007fc64595f110>, @cond=#<Thread::ConditionVariable:0x00007fc645957730>>, @num_waiting=0, @queue=[]>, @lock_thread=false, @reaper=#<ActiveRecord::ConnectionAdapters::ConnectionPool::Reaper:0x00007fc6459575a0 @pool=#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x00007fc64595fe08 ...>, @frequency=60.0>, @schema_cache=#<ActiveRecord::ConnectionAdapters::SpannerSchemaCache:0x00007fc645334c18 @primary_and_parent_keys={}, @connection=#<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x00007fc64519f380 ...>, @columns={"items"=>[#<ActiveRecord::ConnectionAdapters::Column:0x00007fc641c58f78 @name="id", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc641c590b8 @sql_type="integer", @type=:integer, @limit=nil, @precision=nil, @scale=nil>, @null=false, @default=nil, @default_function=nil, @collation=nil, @comment=nil>]}, @columns_hash={"items"=>{"id"=>#<ActiveRecord::ConnectionAdapters::Column:0x00007fc641c58f78 @name="id", @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x00007fc641c590b8 @sql_type="integer", @type=:integer, @limit=nil, @precision=nil, @scale=nil>, @null=false, @default=nil, @default_function=nil, @collation=nil, @comment=nil>}}, @primary_keys={"items"=>"id"}, @data_sources={"items"=>true, "ar_internal_metadata"=>true}, @indexes={}>>, @idle_since=2286266.983776, @visitor=#<Arel::Visitors::SQLite:0x00007fc645161c88 @dispatch={Arel::Nodes::SelectStatement=>"visit_Arel_Nodes_SelectStatement", Arel::Attributes::Attribute=>"visit_Arel_Attributes_Attribute", Arel::Nodes::JoinSource=>"visit_Arel_Nodes_JoinSource", Arel::Table=>"visit_Arel_Table", Arel::Nodes::Equality=>"visit_Arel_Nodes_Equality", Arel::Nodes::BindParam=>"visit_Arel_Nodes_BindParam", Arel::Nodes::Limit=>"visit_Arel_Nodes_Limit", Arel::Nodes::InsertStatement=>"visit_Arel_Nodes_InsertStatement", Arel::Nodes::ValuesList=>"visit_Arel_Nodes_ValuesList"}, @connection=#<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x00007fc64519f380 ...>>, @statements=#<ActiveRecord::ConnectionAdapters::SQLite3Adapter::StatementPool:0x00007fc6451591a0 @cache={56662=>{"SELECT \"ar_internal_metadata\".* FROM \"ar_internal_metadata\" WHERE \"ar_internal_metadata\".\"key\" = ? LIMIT ?"=>#<SQLite3::Statement:0x00007fc641a13ba0 @connection=#<SQLite3::Database:0x00007fc64519fb50 @tracefunc=nil, @authorizer=nil, @encoding=#<Encoding:UTF-8>, @busy_handler=nil, @collations={}, @functions={}, @results_as_hash=true, @type_translation=nil, @type_translator=#<Proc:0x00007fc64190cf68 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.2/lib/sqlite3/database.rb:722 (lambda)>, @readonly=false>, @remainder="", @columns=["key", "value", "created_at", "updated_at"], @types=["varchar", "varchar", "datetime(6)", "datetime(6)"]>}}, @statement_limit=1000>, @lock=#<ActiveSupport::Concurrency::LoadInterlockAwareMonitor:0x00007fc645158660>, @prepared_statements=true, @advisory_locks_enabled=true, @type_map=#<ActiveRecord::Type::TypeMap:0x00007fc6419e4008 @mapping={/boolean/i=>#<Proc:0x00007fc64214fa40 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:648>, /char/i=>#<Proc:0x00007fc64214f7c0 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:648>, /binary/i=>#<Proc:0x00007fc64214f720 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:648>, /text/i=>#<Proc:0x00007fc64214f630 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:648>, /date/i=>#<Proc:0x00007fc64214f4f0 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:655>, /time/i=>#<Proc:0x00007fc64214f3b0 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:655>, /datetime/i=>#<Proc:0x00007fc64214f298 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:655>, /float/i=>#<Proc:0x00007fc64214f158 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:648>, /int/i=>#<Proc:0x00007fc64214de48 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:648>, /blob/i=>#<Proc:0x00007fc64214eb40 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/type/type_map.rb:37>, /clob/i=>#<Proc:0x00007fc64214eaf0 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/type/type_map.rb:37>, /timestamp/i=>#<Proc:0x00007fc64214e960 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/type/type_map.rb:37>, /numeric/i=>#<Proc:0x00007fc64214e898 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/type/type_map.rb:37>, /number/i=>#<Proc:0x00007fc64214e820 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/type/type_map.rb:37>, /double/i=>#<Proc:0x00007fc64214e640 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/type/type_map.rb:37>, /^json/i=>#<Proc:0x00007fc64214e370 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/type/type_map.rb:32>, /decimal/i=>#<Proc:0x00007fc64214df88 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:629>}, @cache=#<Concurrent::Map:0x00007fc64214ff18 entries=3 default_proc=#<Proc:0x00007fc64214fd60 /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/type/type_map.rb:10>>>>
# Did you mean?  current_transaction
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-spanner-adapter-0.6.0/lib/activerecord_spanner_adapter/base.rb:27:in `_insert_record'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/persistence.rb:929:in `_create_record'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/counter_cache.rb:166:in `_create_record'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/locking/optimistic.rb:79:in `_create_record'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/attribute_methods/dirty.rb:201:in `_create_record'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/callbacks.rb:461:in `block in _create_record'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:98:in `run_callbacks'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:824:in `_run_create_callbacks'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/callbacks.rb:461:in `_create_record'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/timestamp.rb:108:in `_create_record'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/persistence.rb:900:in `create_or_update'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/callbacks.rb:457:in `block in create_or_update'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:98:in `run_callbacks'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/callbacks.rb:824:in `_run_save_callbacks'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/callbacks.rb:457:in `create_or_update'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/timestamp.rb:126:in `create_or_update'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/persistence.rb:507:in `save!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/validations.rb:53:in `save!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/transactions.rb:302:in `block in save!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/transactions.rb:302:in `save!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/suppressor.rb:48:in `save!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/persistence.rb:55:in `create!'
#     test1.rb:34:in `test_connection2'
# 
# 2 runs, 0 assertions, 0 failures, 2 errors, 0 skips

Case. 2

require "bundler/inline"

gemfile do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem 'activerecord', '6.1.4'
  gem 'activerecord-spanner-adapter'
  gem 'sqlite3'
end

require "active_record"
require "minitest/autorun"
require 'fileutils'

FileUtils.touch("test.sqlite3")

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: "test.sqlite3")

ActiveRecord::Schema.define do
  create_table :items, force: true do |t|
  end
end

require "active_record/connection_adapters/spanner_adapter"

ActiveRecord::Base.establish_connection(
  adapter: "spanner",
  emulator_host: "localhost:9010",
  project: "spanner-example",
  instance: "spanner-example",
  database: "app-dev",
)

ActiveRecord::Schema.define do
  create_table :user_items, force: true do |t|
  end
end

class UserItem < ActiveRecord::Base
  establish_connection(
    adapter: "spanner",
    emulator_host: "localhost:9010",
    project: "spanner-example",
    instance: "spanner-example",
    database: "app-dev",
  )
end

class Item < ActiveRecord::Base
  establish_connection(adapter: "sqlite3", database: "test.sqlite3")
end

class BugTest < Minitest::Test
  def test_connection
    Item.create
  end
end

# -- create_table(:items, {:force=>true})
#    -> 0.0092s
# -- create_table(:user_items, {:force=>true})
#    -> 0.0572s
# Run options: --seed 2440
# 
# # Running:
# 
# E
# 
# Finished in 0.001647s, 607.1645 runs/s, 0.0000 assertions/s.
# 
#   1) Error:
# BugTest#test_connection:
# ActiveRecord::TransactionIsolationError: SQLite3 only supports the `read_uncommitted` transaction isolation level
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/sqlite3/database_statements.rb:80:in `begin_isolated_db_transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:205:in `materialize!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:285:in `block (2 levels) in materialize_transactions'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:285:in `each'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:285:in `block in materialize_transactions'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:282:in `materialize_transactions'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:328:in `materialize_transactions'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/sqlite3/database_statements.rb:41:in `exec_query'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/sqlite3_adapter.rb:345:in `table_structure'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in `columns'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:112:in `block in columns'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:111:in `fetch'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:111:in `columns'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:120:in `block in columns_hash'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:119:in `fetch'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/schema_cache.rb:119:in `columns_hash'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:553:in `load_schema!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/attributes.rb:250:in `load_schema!'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:539:in `block in load_schema'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:536:in `synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:536:in `load_schema'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/model_schema.rb:402:in `attribute_types'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/attribute_methods.rb:187:in `_has_attribute?'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/inheritance.rb:57:in `new'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/persistence.rb:37:in `create'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-spanner-adapter-0.6.0/lib/activerecord_spanner_adapter/base.rb:22:in `block in create'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/transactions.rb:209:in `transaction'
#     /Users/yasutomo.uemori/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-spanner-adapter-0.6.0/lib/activerecord_spanner_adapter/base.rb:21:in `create'
#     test2.rb:57:in `test_connection'
# 
# 1 runs, 0 assertions, 0 failures, 1 errors, 0 skips

Another information

This patch is workaround, we doesn't recommended to patch to the ActiveRecord::Base and/or activerecord-spanner-adapter doesn't explicit dependent to ActiveRecord::Base . I would liked to suggest using user selective module include style (e.g. include ActiveRecord::SpannerAdapter::Base to spanner model class) or something similar to avoid this.

chore: Update path to release scripts

feat: add support for query hints (#134)

docs: add sample for Partitioned DML (#136)

chore: release activerecord-spanner-adapter 0.7.0 (#135)

docs: Document interleaved table limitation (#138)

perf: inline BeginTransaction with first statement in the transaction (#139)

  • docs: Document interleaved table limitation

  • perf: inline BeginTransaction with first statement

  • feat: add error handling for first statement

  • docs: add more comments

chore: release activerecord-spanner-adapter 0.7.1 (#141)

docs: add unique index to interleaved table sample (#142)

Interleaved child tables should have a unique index on the child id column to prevent full table scans when a single child record is fetched by ActiveRecord. ActiveRecord will only use the child id column when fetching a record, and this query will not use the primary key of the table, as that primary key starts with the parent id column(s).

chore: cast COLUMN_DEFAULT to STRING (#143)

chore: remove sample for interleaved table (#144)

Co-authored-by: Hengfeng Li hengfeng@google.com

chore: release 1.0.0 (#145)

Release-As: 1.0.0

feat: release 1.0.0 (#146)

Release-As: 1.0.0

chore: release activerecord-spanner-adapter 1.0.0 (#148)

chore: Fix default branch in a bunch of workflow configs (#149)

chore: auto-assign issues to Spanner owner (#150)

chore(deps): update dependency minitest to ~> 5.15.0 (#152)

docs: fix a couple of minor formatting issues (#153)

Fixes a couple of minor formatting issues in the README file.

chore(deps): update actions/cache action to v2 (#154)

Created at 3 weeks ago