Skip to content

Commit 8029660

Browse files
authored
Merge pull request #1152 from JesseChavez/rails_71_support_mysql
Fix some arjdbc mysql tests to support AR 7.1
2 parents d8ec034 + d3872dd commit 8029660

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

lib/arjdbc/mysql/adapter.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def initialize(...)
5858
@connection_parameters ||= @config
5959
end
6060

61+
# NOTE: redefines constant defined in abstract class however this time
62+
# will use methods defined in the mysql abstract class and map properly
63+
# mysql types.
64+
TYPE_MAP = Type::TypeMap.new.tap { |m| initialize_type_map(m) }
65+
6166
def self.database_exists?(config)
6267
conn = ActiveRecord::Base.mysql2_connection(config)
6368
conn && conn.really_valid?
@@ -239,6 +244,8 @@ def translate_exception(exception, message:, sql:, binds:)
239244
case message
240245
when /Table .* doesn't exist/i
241246
StatementInvalid.new(message, sql: sql, binds: binds, connection_pool: @pool)
247+
when /BLOB, TEXT, GEOMETRY or JSON column .* can't have a default value/i
248+
StatementInvalid.new(message, sql: sql, binds: binds, connection_pool: @pool)
242249
else
243250
super
244251
end

test/db/mysql/change_column_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class MySQLChangeColumnTest < Test::Unit::TestCase
1313
ActiveRecord::Migration.add_column :people, :about, :string, :default => 'x'
1414
# NOTE: even in non strict mode MySQL does not allow us add or change
1515
# text/binary with a default ...
16+
# Message: BLOB, TEXT, GEOMETRY or JSON column '%s' can't have a default value
1617
if mariadb_server? && db_version >= '10.2'
1718
ActiveRecord::Migration.change_column :people, :about, :text
1819
else

test/db/mysql/schema_dump_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ def test_schema_dump_should_not_have_limits_on_date
132132

133133
def test_should_include_limit
134134
text_column = connection.columns('memos').find { |c| c.name == 'text' }
135-
assert_equal 4294967295, text_column.limit
135+
136+
assert_equal 4_294_967_295, text_column.limit
136137
end
137138

138139
def test_should_set_sqltype_to_longtext

test/db/mysql/simple_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,10 @@ def test_execute_after_disconnect
451451

452452
# active record change of behaviour 7.1, reconnects on query execution.
453453
result = assert_nothing_raised do
454-
connection.execute('SELECT 1 + 2')
454+
connection.execute('SELECT 1 + 2 as total')
455455
end
456456

457-
assert_equal 3, result.rows.flatten.first
457+
assert_equal 3, result.first['total']
458458
ensure
459459
connection.reconnect!
460460
end

0 commit comments

Comments
 (0)