aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/mysql2/connection_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* activerecord/test: Fix Mysql2ConnectionTest#test_execute_after_disconnectDylan Thacker-Smith2017-01-091-1/+2
| | | | | | | | | | | | | Mysql2ConnectionTest#test_execute_after_disconnect was originally added to catch a NoMethodError occuring in execute when the Mysql2Adapter has a nil `@connection`. Pull request #26869 removed the error message check in that test because the error message changed in the mysql2 gem, which caused the test to fail. Now the test wouldn't catch the original bug since the NoMethodError would get turned into a ActiveRecord::StatementInvalid exception. Check the cause of the StatementInvalid exception to make sure it is of the correct type.
* Privatize unneededly protected methods in Active Record testsAkira Matsuda2016-12-241-1/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Fix brittle tests which were relying on the error message text from mysql2 gemPrathamesh Sonpatki2016-10-231-4/+4
| | | | | | | - These tests were fixed earlier on master in https://github.com/rails/rails/commit/f13ec72664fd13d33d617103ca964a7592295854. - They started failing in first place due to change in https://github.com/brianmario/mysql2/commit/f14023fcfee9e85e6fc1b0e568048811518f8c23. - They will fail again when the message is changed in mysql2 so let's not rely on the error message.
* Update mysql adapter error message when disconnectedGuillermo Iguaran2016-10-221-2/+2
|
* Address `warning: ambiguous first argument; put parentheses or a space even ↵Yasuo Honda2016-09-131-2/+2
| | | | after `/' operator`
* activerecord/mysql2: Avoid setting @connection to nil, just close itDylan Thacker-Smith2016-09-081-0/+21
| | | | | | | | | | By doing `@connection = nil` that means that we need nil checks before it is used anywhere, but we weren't doing those checks. Instead, we get a NoMethodError after using a connection after it fails to reconnect. Neither of the other adapters set @connection to nil, just the mysql2 adapter. By just closing it, we avoid the need to check if we have a connection object and it will produce an appropriate exception when used.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-4/+4
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-2/+2
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-16/+16
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Should quote `lock_name` to pass to `get_advisory_lock`Ryuta Kamizono2016-05-101-3/+3
|
* Append sql_mode instead of overwriting in strict modeRyuta Kamizono2016-03-131-25/+25
| | | | For keep the default SQL mode.
* Add support for passing flags to MySQL2 adapter by arrayStephen Blackstone2015-12-221-1/+8
|
* Remove legacy mysql adapterRyuta Kamizono2015-12-211-4/+1
| | | | Follow up to #22642.
* Allow users to pass flags from database.ymlStephen Blackstone2015-12-151-0/+7
| | | | | | Fix white-space Add test case demonstrating flags are received by the adapter
* Rename 'key' to 'lock_id' or 'lock_name' for advisory lockingSam Davies2015-11-181-9/+9
| | | | | | | | | - key was a poor choice of name. A key implies something that will unlock a lock. The concept is actually more like a 'lock identifier' - mysql documentation calls this a 'lock name' - postgres documentation calls it a 'lock_id' - Updated variable names to reflect the preferred terminology for the database in question
* Use advisory locks to prevent concurrent migrationsSam Davies2015-10-301-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Addresses issue #22092 - Works on Postgres and MySQL - Uses advisory locks because of two important properties: 1. The can be obtained outside of the context of a transaction 2. They are automatically released when the session ends, so if a migration process crashed for whatever reason the lock is not left open perpetually - Adds get_advisory_lock and release_advisory_lock methods to database adapters - Attempting to run a migration while another one is in process will raise a ConcurrentMigrationError instead of attempting to run in parallel with undefined behavior. This could be rescued and the migration could exit cleanly instead. Perhaps as a configuration option? Technical Notes ============== The Migrator uses generate_migrator_advisory_lock_key to build the key for the lock. In order to be compatible across multiple adapters there are some constraints on this key. - Postgres limits us to 64 bit signed integers - MySQL advisory locks are server-wide so we have to scope to the database - To fulfil these requirements we use a Migrator salt (a randomly chosen signed integer with max length of 31 bits) that identifies the Rails migration process as the owner of the lock. We multiply this salt with a CRC32 unsigned integer hash of the database name to get a signed 64 bit integer that can also be converted to a string to act as a lock key in MySQL databases. - It is important for subsequent versions of the Migrator to use the same salt, otherwise different versions of the Migrator will not see each other's locks.
* make it possible to run AR tests with bin/testYves Senn2015-06-111-1/+1
|
* If specify `strict: :default` explicitly, do not set sql_mode.Ryuta Kamizono2015-05-261-0/+9
| | | | Related with #17370.
* prefer `drop_table if_exists: true` over raw SQL.Yves Senn2015-02-181-1/+1
| | | | | | | /cc @yahonda This makes it easier for third party adapters to run our tests, even if that database does not support IF EXISTS.
* Refactor microsecond precision to be database agnosticSean Griffin2015-02-101-7/+0
| | | | | | | | | | The various databases don't actually need significantly different handling for this behavior, and they can achieve it without knowing about the type of the object. The old implementation was returning a string, which will cause problems such as breaking TZ aware attributes, and making it impossible for the adapters to supply their logic for time objects.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-3/+1
|
* add a truncate method to the connectionAaron Patterson2014-09-221-0/+13
| | | | | | it doesn't work on SQLite3 since it doesn't support truncate, but that's OK. If you call truncate on the connection, you're now bound to that database (same as if you use hstore or any other db specific feature).
* MySQL: set connection collation along with the charsetJeremy Kemper2014-08-301-0/+5
| | | | | | | | | | Sets the connection collation to the database collation configured in database.yml. Otherwise, `SET NAMES utf8mb4` will use the default collation for that charset (utf8mb4_general_ci) when you may have chosen a different collation, like utf8mb4_unicode_ci. This only applies to literal string comparisons, not column values, so it is unlikely to affect you.
* [ci skip] fix spelling of overrideAkshay Vishnoi2014-08-131-1/+1
|
* Revert "Rename to test_mysql_strict_mode_disabled_dont_override_global_sql_mode"Yasuo Honda2014-07-171-4/+3
| | | | | | | | | This reverts commit babc24c1b07c1fd58b9b3249b0256f9b0d45c0f0. Conflicts: activerecord/test/cases/adapters/mysql/connection_test.rb activerecord/test/cases/adapters/mysql2/connection_test.rb
* Stringify variables names for mysql connectionsPaul Nikitochkin2014-04-301-0/+8
| | | | | | | For mysql2/mysql adapters, `sql_mode` variable name set in `database.yml` as string, was ignored and `sql_mode` was set to use strict mode. Fixes #14895
* Add ConnectionHelper to refactor tests.Guo Xiang Tan2014-04-031-11/+3
|
* Fix tests not unsubscribing from Notifications.Guo Xiang Tan2014-03-281-2/+2
| | | | See https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb#L131
* Unit test for mysql quote time usecArthur Neves2014-03-121-0/+7
|
* Change the inexistent database name to inexistent_activerecord_unittestYasuo Honda2014-01-011-1/+1
| | | | | | to make this grant statement described in the document works GRANT ALL PRIVILEGES ON inexistent_activerecord_unittest.* to 'rails'@'localhost';
* used user-defined configurations for running tests that might depend on ↵Kuldeep Aggarwal2013-12-291-1/+2
| | | | user's system configuration
* Move mysql2 test for when adapter will be loadedschneems2013-12-241-0/+7
| | | | | | When run with only the Mysql adapter, we get this failure: https://travis-ci.org/rails/rails/jobs/15937907#L2416 Porting the test over to only run when mysql2 is loaded
* Remove tests for not swallowing exceptions.Doug Barth2013-11-151-21/+0
| | | | From PR, @tenderlove would prefer to not maintain these tests.
* Don't swallow exceptions in transctional statementsDoug Barth2013-11-051-0/+26
| | | | | | | | | | | | | | | | | | | | The MySQL connection adapater swallows all StandardError exceptions, which includes Mysql::Error and Mysql2::Error. The comment in the exception clause claims errors thrown here indicate that transactions aren't supported by the server but that isn't necessarily true. It's possible the MySQL server has gone away and swallowing a failed commit may let the application return a successful response when the data has not been saved. Also, replication libraries like Galera require that the application handle exceptions thrown at BEGIN/COMMIT. I'm unable to determine what version of MySQL threw an exception for transactional statements. I tried as far back as 3.23.49 with InnoDB disabled but BEGIN & COMMIT statements do not throw an error. If there's a real case for this logic to continue, we could instead push this behavior into a configuration setting. The exception swallowing has been there since the beginning: db045dbbf60b53dbe013ef25554fd013baf88134
* stop adding singleton methods to the mysql2 adapterAaron Patterson2013-10-041-7/+7
|
* `Connection#structure_dump` is no longer used. #9518Yves Senn2013-03-061-6/+0
| | | | | | | As of ccc6910c we use `mysqldump` to create the `structure.sql`. The old `#structure_dump` code is still in AR but never used. I removed all relevant parts from the code-base.
* Session variables for mysql, mysql2, and postgresql adapters can be setAaron Stone2012-12-081-0/+17
| | | | | | | | | in the new 'variables:' hash in each database config section in database.yml. The key-value pairs of this hash will be sent in a 'SET key = value, ...' query on new database connections. The configure_connection methods from mysql and mysql2 into are consolidated into the abstract_mysql base class.
* Remove ActiveRecord::ModelJon Leighton2012-10-261-6/+6
| | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* Rename to test_mysql_strict_mode_disabled_dont_override_global_sql_modeYasuo Honda2012-08-221-3/+4
| | | | | | | | | Reason since MySQL 5.6.6-m9 the `sql_mode` default value is `NO_ENGINE_SUBSTITUTION`. This default parameter change is out of control from Rails. This test verifies Rails not overriding the default `@@GLOBAL.sql_mode` value by checking if `@@GLOBAL.sql_mode` is the same as `@@SESSION.sql_mode`.
* Fix logs name consistency.kennyj2012-05-191-0/+27
|
* Add config option, rdoc, tests for mysql(2) STRICT_ALL_TABLES mode.Michael Pearson2012-05-051-0/+16
|
* Fix CIJon Leighton2011-12-281-3/+3
|
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* avoids warnings about mismatched indentations in Ruby 1.9.2Xavier Noria2010-08-191-1/+1
|
* update tests for mysql2 supportBrian Lopez2010-08-021-0/+42