Skip to content

Commit 05349c2

Browse files
committed
Fix mysql test failing due some types can't have default
<ActiveRecord::StatementInvalid> expected but was <ActiveRecord::JDBCError(<java.sql.SQLSyntaxErrorException: BLOB, TEXT, GEOMETRY or JSON column 'about' can't have a default value>)
1 parent dc42f25 commit 05349c2

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/arjdbc/mysql/adapter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ def translate_exception(exception, message:, sql:, binds:)
239239
case message
240240
when /Table .* doesn't exist/i
241241
StatementInvalid.new(message, sql: sql, binds: binds, connection_pool: @pool)
242+
when /BLOB, TEXT, GEOMETRY or JSON column .* can't have a default value/i
243+
StatementInvalid.new(message, sql: sql, binds: binds, connection_pool: @pool)
242244
else
243245
super
244246
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

0 commit comments

Comments
 (0)