Skip to content

Commit dfe9208

Browse files
committed
correct JRuby specific expected query count (since tables/table_exists? are using JDBC)
1 parent e5c9483 commit dfe9208

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/db/mysql/simple_test.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,13 @@ def test_mysql_indexes
341341
# ALTER TABLE `bulks` ADD UNIQUE INDEX awesome_username_index (`username`), ADD INDEX index_bulks_on_name_and_age (`name`, `age`)
342342

343343
# Adding an index fires a query every time to check if an index already exists or not
344-
assert_queries( ar_version('4.2') ? 5 : 3 ) do
344+
expected_query_count = 3
345+
if ar_version('4.2')
346+
expected_query_count = 5 # MRI
347+
# no SHOW TABLES LIKE 'bulks' in JRuby since we do table_exists? with JDBC APIs
348+
expected_query_count -= 2 if defined? JRUBY_VERSION
349+
end
350+
assert_queries( expected_query_count ) do
345351
with_bulk_change_table(:bulks) do |t|
346352
t.index :username, :unique => true, :name => :awesome_username_index
347353
t.index [:name, :age]
@@ -368,7 +374,13 @@ def test_mysql_indexes
368374
# SHOW TABLES LIKE 'bulks'
369375
# SHOW KEYS FROM `bulks`
370376
# ALTER TABLE `bulks` DROP INDEX index_bulks_on_name2, ADD UNIQUE INDEX new_name2_index (`name2`)
371-
assert_queries( ar_version('4.2') ? 4 : 3 ) do
377+
expected_query_count = 3
378+
if ar_version('4.2')
379+
expected_query_count = 4 # MRI
380+
# no SHOW TABLES LIKE 'bulks' in JRuby since we do table_exists? with JDBC APIs
381+
expected_query_count -= 1 if defined? JRUBY_VERSION
382+
end
383+
assert_queries( expected_query_count ) do
372384
with_bulk_change_table('bulks') do |t|
373385
t.remove_index :name2
374386
t.index :name2, :name => :new_name2_index, :unique => true

0 commit comments

Comments
 (0)