From dc42f25de5258ed2de1a93e18c045478c275d9ec Mon Sep 17 00:00:00 2001 From: Jesse Chavez Date: Fri, 26 Jul 2024 19:18:01 +1000 Subject: [PATCH 1/3] Fix mysql execute test after disconnect. Previously it used to be ActiveRecord::Result, now it seems to be an array --- test/db/mysql/simple_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/db/mysql/simple_test.rb b/test/db/mysql/simple_test.rb index ac88db694..4a73cb1a8 100644 --- a/test/db/mysql/simple_test.rb +++ b/test/db/mysql/simple_test.rb @@ -451,10 +451,10 @@ def test_execute_after_disconnect # active record change of behaviour 7.1, reconnects on query execution. result = assert_nothing_raised do - connection.execute('SELECT 1 + 2') + connection.execute('SELECT 1 + 2 as total') end - assert_equal 3, result.rows.flatten.first + assert_equal 3, result.first['total'] ensure connection.reconnect! end From 05349c287e2833ba787749453c0790e2ead87da0 Mon Sep 17 00:00:00 2001 From: Jesse Chavez Date: Fri, 26 Jul 2024 19:20:42 +1000 Subject: [PATCH 2/3] Fix mysql test failing due some types can't have default expected but was ) --- lib/arjdbc/mysql/adapter.rb | 2 ++ test/db/mysql/change_column_test.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/arjdbc/mysql/adapter.rb b/lib/arjdbc/mysql/adapter.rb index 36d074ebe..78e56cc5c 100644 --- a/lib/arjdbc/mysql/adapter.rb +++ b/lib/arjdbc/mysql/adapter.rb @@ -239,6 +239,8 @@ def translate_exception(exception, message:, sql:, binds:) case message when /Table .* doesn't exist/i StatementInvalid.new(message, sql: sql, binds: binds, connection_pool: @pool) + when /BLOB, TEXT, GEOMETRY or JSON column .* can't have a default value/i + StatementInvalid.new(message, sql: sql, binds: binds, connection_pool: @pool) else super end diff --git a/test/db/mysql/change_column_test.rb b/test/db/mysql/change_column_test.rb index bdffb3c18..97eec41cb 100644 --- a/test/db/mysql/change_column_test.rb +++ b/test/db/mysql/change_column_test.rb @@ -13,6 +13,7 @@ class MySQLChangeColumnTest < Test::Unit::TestCase ActiveRecord::Migration.add_column :people, :about, :string, :default => 'x' # NOTE: even in non strict mode MySQL does not allow us add or change # text/binary with a default ... + # Message: BLOB, TEXT, GEOMETRY or JSON column '%s' can't have a default value if mariadb_server? && db_version >= '10.2' ActiveRecord::Migration.change_column :people, :about, :text else From d3872dd4f36a9f36933a05ca576a1887c435cc21 Mon Sep 17 00:00:00 2001 From: Jesse Chavez Date: Fri, 26 Jul 2024 20:03:32 +1000 Subject: [PATCH 3/3] Fix mysql test must contain limit, redefines TYPE_MAP to properly map mysql types --- lib/arjdbc/mysql/adapter.rb | 5 +++++ test/db/mysql/schema_dump_test.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/arjdbc/mysql/adapter.rb b/lib/arjdbc/mysql/adapter.rb index 78e56cc5c..aee99b6ab 100644 --- a/lib/arjdbc/mysql/adapter.rb +++ b/lib/arjdbc/mysql/adapter.rb @@ -58,6 +58,11 @@ def initialize(...) @connection_parameters ||= @config end + # NOTE: redefines constant defined in abstract class however this time + # will use methods defined in the mysql abstract class and map properly + # mysql types. + TYPE_MAP = Type::TypeMap.new.tap { |m| initialize_type_map(m) } + def self.database_exists?(config) conn = ActiveRecord::Base.mysql2_connection(config) conn && conn.really_valid? diff --git a/test/db/mysql/schema_dump_test.rb b/test/db/mysql/schema_dump_test.rb index c2ea40f8d..b2ac5c5e1 100644 --- a/test/db/mysql/schema_dump_test.rb +++ b/test/db/mysql/schema_dump_test.rb @@ -132,7 +132,8 @@ def test_schema_dump_should_not_have_limits_on_date def test_should_include_limit text_column = connection.columns('memos').find { |c| c.name == 'text' } - assert_equal 4294967295, text_column.limit + + assert_equal 4_294_967_295, text_column.limit end def test_should_set_sqltype_to_longtext