aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/mysql2
Commit message (Collapse)AuthorAgeFilesLines
...
* | 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
|/
* Serialize JSON attribute value nil as SQL NULL, not JSON 'null'Trung Duc Tran2016-09-231-0/+16
| | | | | | Test: JSON attribute value nil can be used in where(attr: nil) Add changelog entry
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-3/+3
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* 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.
* Remove unused `blob_or_text_column?` methodRyuta Kamizono2016-08-191-5/+0
|
* Add three new rubocop rulesRafael Mendonça França2016-08-165-21/+21
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-062-2/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-065-168/+168
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-062-9/+9
|
* modernizes hash syntax in activerecordXavier Noria2016-08-065-34/+34
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-0618-149/+149
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* The problem isn't the detection but the deadlock itselfDavid Heinemeier Hansson2016-08-041-2/+2
|
* Merge pull request #25107 from Erol/introduce-new-ar-transaction-error-classesRafael Mendonça França2016-08-031-20/+13
|\ | | | | | | | | | | Introduce new ActiveRecord transaction error classes Closes #26018
| * Introduce new ActiveRecord transaction error classesErol Fornoles2016-05-241-20/+13
| |
* | Extract foreign key action from `information_schema`Ryuta Kamizono2016-06-071-0/+21
| | | | | | | | Fixes #25300.
* | Do not include default column limit in schema.rbRyuta Kamizono2016-05-311-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up of #20815. ```ruby class CreatePeople < ActiveRecord::Migration[5.0] def change create_table :people do |t| t.integer :int t.bigint :bint t.text :txt t.binary :bin end end end ``` Result. In postgresql and sqlite3 adapters: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade do |t| t.integer "int" t.bigint "bint" t.text "txt" t.binary "bin" end end ``` In mysql2 adapter: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t| t.integer "int" t.bigint "bint" t.text "txt", limit: 65535 t.binary "bin", limit: 65535 end end ``` After this patch: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t| t.integer "int" t.bigint "bint" t.text "txt" t.binary "bin" end end ```
* Add AR::TransactionSerializationError for transaction serialization failures ↵Erol Fornoles2016-05-211-0/+62
| | | | or deadlocks
* Should quote `lock_name` to pass to `get_advisory_lock`Ryuta Kamizono2016-05-101-3/+3
|
* Followup of #24835Vipul A M2016-05-031-2/+2
| | | | Fix failing tests
* Extract `add_sql_comment!` methodRyuta Kamizono2016-04-291-3/+3
| | | | | | Refactor of #22911. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Dont simply assume a type is a valid database type. This is only always true ↵Vipul A M2016-04-251-0/+11
| | | | | | | in the case of sqlite. Others adapters need to perform a check for validity. Add coverage for mysql2 db type validation
* Properly serialize all JSON primitives in the AR JSON typeSean Griffin2016-04-131-4/+11
| | | | | | | | | | | | | | Previously we were assuming that the only valid types for encoding were arrays and hashes. However, any JSON primitive is an accepted value by both PG and MySQL. This does involve a minor breaking change in the handling of `default` in the schema dumper. This is easily worked around, as passing a hash/array literal would have worked fine in previous versions of Rails. However, because of this, I will not be backporting this to 4.2 or earlier. Fixes #24234
* Support microsecond datetime precision on MariaDB 5.3+.Jeremy Daer2016-04-082-21/+45
| | | | | | | | | We support microsecond datetime precision for MySQL 5.6.4+. MariaDB has supported it since 5.3.0, but even 10.x versions return a compatible version string like `5.5.5-10.1.8-MariaDB-log` which we parse as 5.5.5, before MySQL supported microsecond precision. Specialize our version check to account for MariaDB to fix.
* Use `QUOTED_TRUE` and `QUOTED_FALSE` instead of magic stringsyui-knk2016-04-051-2/+12
| | | | | | Because we define `QUOTED_TRUE` as `"1"` and `QUOTED_FALSE` as `"0"`. And add test cases to ensure this commit does not break current behavior even if the value of `attributes_before_type_cast` is false.
* Append sql_mode instead of overwriting in strict modeRyuta Kamizono2016-03-131-25/+25
| | | | For keep the default SQL mode.
* Merge pull request #23797 from ↵Rafael França2016-03-111-0/+9
|\ | | | | | | | | kamipo/case_sensitive_comparison_for_non_string_column The BINARY Operator is only needed for string columns
| * The BINARY Operator is only needed for string columnsRyuta Kamizono2016-02-221-0/+9
| | | | | | | | Follow up to #13040.
* | Dump `bigint` instead of `integer` with `limit: 8` for schema dumperRyuta Kamizono2016-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ```ruby create_table "big_numbers", force: :cascade do |t| t.integer "bigint_column", limit: 8 end ``` After: ```ruby create_table "big_numbers", force: :cascade do |t| t.bigint "bigint_column" end ```
* | Merge pull request #23953 from ↵Rafael França2016-03-011-19/+13
|\ \ | | | | | | | | | | | | kamipo/fix_tests_failure_with_prepared_statements_false Fix tests failure with `prepared_statements: false`
| * | Remove unnecessary namespaces in `explain_test.rb`Ryuta Kamizono2016-02-291-19/+13
| |/
* / Fix `NoMethodError: undefined method `fields' for nil:NilClass`Ryuta Kamizono2016-02-291-0/+18
|/ | | | | | | | | | | | | | | | | Currently `exec_query` raises `NoMethodError` when executing no result queries (`INSERT`, `UPDATE`, `DELETE`, and all DDL) in mysql2 adapter. ``` irb(main):002:0> conn.execute("create table t(a int)") (43.3ms) create table t(a int) => nil irb(main):003:0> conn.execute("insert into t values (1)") (19.3ms) insert into t values (1) => nil irb(main):004:0> conn.exec_query("insert into t values (1)") SQL (28.6ms) insert into t values (1) NoMethodError: undefined method `fields' for nil:NilClass ```
* Avoid extra `show variables` in migrationRyuta Kamizono2016-02-011-5/+0
| | | | | | | | | | | | | `initialize_schema_migrations_table` is called in every migrations. https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/migration.rb#L1080 https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/schema.rb#L51 This means that extra `show variables` is called regardless of the existence of `schema_migrations` table. This change is to avoid extra `show variables` if `schema_migrations` table exists.
* Fix `bigint?` for Enum columns in MySQLRyuta Kamizono2016-01-311-0/+5
| | | | Follow up to #22896.
* [close #23009] Limit key lengthschneems2016-01-211-7/+29
| | | | | | | Mysql has a weird bug where it cannot index a string column of utf8mb4 if it is over a certain character limit. To get compatibility with msql we can add a limit to the key column. 191 characters is a very long key, it seems reasonable to limit across all adapters since using a longer key wouldn't be supported in mysql. Thanks to @kamipo for the original PR and the test refactoring. Conversation: https://github.com/rails/rails/pull/23009#issuecomment-171416629
* Fix `unsigned?` and `blob_or_text_column?` for Enum columns in MySQLRyuta Kamizono2016-01-041-1/+12
|
* Merge pull request #22241 from kamipo/add_columns_for_distinct_for_mysql57Rafael França2015-12-301-0/+44
|\ | | | | Add `columns_for_distinct` for MySQL 5.7 with ONLY_FULL_GROUP_BY
| * Add `columns_for_distinct` for MySQL 5.7 with ONLY_FULL_GROUP_BYRyuta Kamizono2015-12-231-0/+44
| | | | | | | | | | | | | | | | | | In MySQL 5.7.5 and up, ONLY_FULL_GROUP_BY affects handling of queries that use DISTINCT and ORDER BY. It requires the ORDER BY columns in the select list for distinct queries, and requires that the ORDER BY include the distinct column. See https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
* | Improve `select_one` in `Mysql2Adapter`Ryuta Kamizono2015-12-271-0/+6
| | | | | | | | | | Avoid instanciate `ActiveRecord::Result` and calling `ActiveRecord::Result#hash_rows` for the performance.
* | 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.
* These limits are now implicitMatthew Draper2015-12-182-2/+2
|
* 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
* Fix test failure in `adapters/mysql/active_schema_test.rb`Ryuta Kamizono2015-11-201-1/+1
| | | | Follow up to #21601.
* 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
* Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes`yui-knk2015-11-092-8/+8
| | | | | | | | | | Reported on #21509, how views is treated by `#tables` are differ by each adapters. To fix this different behavior, after Rails 5.0 is released, deprecate `#tables`. And `#table_exists?` would check both tables and views. To make their behavior consistent with `#tables`, after Rails 5.0 is released, deprecate `#table_exists?`.
* No need `MysqlDouble` and `MysqlDouble.reset_column_information`Ryuta Kamizono2015-11-051-12/+6
|
* Add test_float_limits to mysql2yui-knk2015-11-031-0/+37
| | | | | | This test case was definded by 51de8cee82d61541725ff4c2462b083f37e64017. `float` and `double` is registered in abstract_mysql_adapter.rb, we should test not only for mysql adapter, but mysql2 adapter.
* Merge pull request #22122 from ↵Sean Griffin2015-10-301-0/+28
|\ | | | | | | | | samphilipd/sam/manual_locking_on_schema_migrations Make migrations concurrent safe (using advisory locks)