Created
February 4, 2011 22:46
-
-
Save mghaught/811933 to your computer and use it in GitHub Desktop.
database_cleaner - mysql2 oddity with second connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Truncation performed on main DB: | |
mysql2 - disable_referential_integrity - 1 | |
>> mysql2 - active? true | |
SQL (0.1ms) SET FOREIGN_KEY_CHECKS = 0 | |
>> disabled referential integrity | |
SQL (0.4ms) SHOW TABLES | |
SQL (0.1ms) SELECT DATABASE() as db | |
SQL (0.7ms) select table_name from information_schema.views where table_schema = 'tnation_forums_test' | |
>> truncating categories | |
SQL (1.1ms) TRUNCATE TABLE `categories`; | |
>> DBC - connection active? true | |
>> completed disabled referential integrity - active? true | |
>> mysql2 - active? at end of block true | |
mysql2 - disable_referential_integrity ENSURE - 1 | |
>> mysql2 - active? true | |
SQL (0.1ms) SET FOREIGN_KEY_CHECKS = 1 | |
>> Finished clean | |
You can see that it worked just fine across DBC and mysql2 | |
Here's the same action on the second connection: | |
SQL (0.1ms) SELECT @@FOREIGN_KEY_CHECKS | |
mysql2 - disable_referential_integrity - 1 | |
>> mysql2 - active? true | |
SQL (0.1ms) SET FOREIGN_KEY_CHECKS = 0 | |
>> disabled referential integrity | |
SQL (0.5ms) SHOW TABLES | |
SQL (0.1ms) SELECT DATABASE() as db | |
SQL (0.9ms) select table_name from information_schema.views where table_schema = 'tnation_admin_test' | |
>> truncating addresses | |
SQL (1.1ms) TRUNCATE TABLE `addresses`; | |
>> DBC - connection active? true | |
>> truncating carts | |
SQL (1.3ms) TRUNCATE TABLE `carts`; | |
>> DBC - connection active? true | |
... <SNIPPED A BUNCH OF TABLES> ... | |
>> truncating zones | |
SQL (1.1ms) TRUNCATE TABLE `zones`; | |
>> DBC - connection active? true | |
>> completed disabled referential integrity - active? true | |
>> mysql2 - active? at end of block false | |
mysql2 - disable_referential_integrity ENSURE - 1 | |
>> mysql2 - active? false | |
>> DOH!!! error - undefined method `query_options' for nil:NilClass | |
So something happened to the connection between the end of the connection.disable_referential_integrity call in DBC's AR truncation.db file and mysql2's disable_referential_integrity end of the yield. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment