aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Support Descending Indexes for MySQLRyuta Kamizono2017-04-161-3/+1
| | | | | | | MySQL 8.0.1 and higher supports descending indexes: `DESC` in an index definition is no longer ignored. See https://dev.mysql.com/doc/refman/8.0/en/descending-indexes.html.
* Refactor `indexes` things in connection adaptersRyuta Kamizono2017-04-161-33/+0
| | | | | | | * Use keyword arguments in `IndexDefinition` to ease to ignore unused options and to avoid to initialize incorrect empty value. * Place it in `SchemaStatements` for consistency. * And tiny tweaks.
* Make internal methods to privateRyuta Kamizono2017-03-271-35/+2
|
* Merge pull request #28068 from kamipo/refactor_data_sourcesRafael França2017-03-131-67/+12
|\ | | | | Extract `data_source_sql` to refactor data source statements
| * Extract `data_source_sql` to refactor data source statementsRyuta Kamizono2017-02-201-67/+12
| |
* | Deprecate `supports_migrations?` on connection adaptersRyuta Kamizono2017-02-271-5/+0
| | | | | | | | | | | | | | `supports_migrations?` was added at 4160b518 to determine if schema statements (`create_table`, `drop_table`, etc) are implemented in the adapter. But all tested databases has been supported migrations since a4fc93c3 at least.
* | Merge pull request #28176 from kamipo/push_valid_type_up_to_abstract_adapterAndrew White2017-02-261-4/+0
|\ \ | | | | | | Push `valid_type?` up to abstract adapter
| * | Push `valid_type?` up to abstract adapterRyuta Kamizono2017-02-261-4/+0
| | | | | | | | | | | | | | | | | | | | | `valid_type?` should return true if a type exists in `native_database_types` at least. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/schema_dumper.rb#L136
* | | Fix `change_column` to drop default with `null: false`Ryuta Kamizono2017-02-261-2/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently `change_column` cannot drop default if `null: false` is specified at the same time. This change fixes the issue. ```ruby # cannot drop default change_column "tests", "contributor", :boolean, default: nil, null: false # we need the following workaround currently change_column "tests", "contributor", :boolean, null: false change_column "tests", "contributor", :boolean, default: nil ``` Closes #26582
* | Fix `wait_timeout` to configurable for mysql2 adapterRyuta Kamizono2017-02-241-2/+2
| | | | | | | | Fixes #26556.
* | Correctly dump native timestamp types for MySQLRyuta Kamizono2017-02-231-1/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The native timestamp type in MySQL is different from datetime type. Internal representation of the timestamp type is UNIX time, This means that timestamp columns are affected by time zone. ``` > SET time_zone = '+00:00'; Query OK, 0 rows affected (0.00 sec) > INSERT INTO time_with_zone(ts,dt) VALUES (NOW(),NOW()); Query OK, 1 row affected (0.02 sec) > SELECT * FROM time_with_zone; +---------------------+---------------------+ | ts | dt | +---------------------+---------------------+ | 2016-02-07 22:11:44 | 2016-02-07 22:11:44 | +---------------------+---------------------+ 1 row in set (0.00 sec) > SET time_zone = '-08:00'; Query OK, 0 rows affected (0.00 sec) > SELECT * FROM time_with_zone; +---------------------+---------------------+ | ts | dt | +---------------------+---------------------+ | 2016-02-07 14:11:44 | 2016-02-07 22:11:44 | +---------------------+---------------------+ 1 row in set (0.00 sec) ```
* Add `default_index_type?` to the generic schema dumper doesn't have the ↵Ryuta Kamizono2017-02-141-0/+4
| | | | knowledge about an index type
* Deprecate `supports_primary_key?`Ryuta Kamizono2017-02-121-4/+0
| | | | | | | | | | | | `supports_primary_key?` was added to determine if `primary_key` is implemented in the adapter in f060221. But we already use `primary_key` without `supports_primary_key?` (207f266, 5f3cf42) and using `supports_primary_key?` has been removed in #1318. This means that `supports_primary_key?` is no longer used in the internal and Active Record doesn't work without `primary_key` is implemented (all adapters must implement `primary_key`). Closes #27977
* Refactor `ColumnDefinition` to contain `options` hashRyuta Kamizono2017-02-091-2/+2
| | | | | | Column options are passed as an hash args then used as `options` hash in `add_column_options!`. Converting args to attributes is inconvinient for using options as an hash.
* Merge pull request #26378 from ↵Jeremy Daer2017-02-061-2/+2
|\ | | | | | | | | kamipo/decouple_building_arel_ast_for_uniqueness_validator Decouple the building Arel ASTs for uniqueness validator
| * Add `:nodoc:` to `case_sensitive_comparison` and `case_insensitive_comparison`Ryuta Kamizono2017-01-201-1/+1
| | | | | | | | These methods are obviously for internal use.
| * Decouple the building Arel ASTs for uniqueness validatorRyuta Kamizono2016-12-251-1/+1
| | | | | | | | | | | | Currently uniqueness validator is coupled with building Arel ASTs. This commit extracts `WhereClauseFactory#build_for_case_sensitive` for decouple the building Arel ASTs.
* | Virtual/generated column support for MySQL 5.7.5+ and MariaDB 5.2.0+Ryuta Kamizono2017-02-011-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL generated columns: https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html MariaDB virtual columns: https://mariadb.com/kb/en/mariadb/virtual-computed-columns/ Declare virtual columns with `t.virtual name, type: …, as: "expression"`. Pass `stored: true` to persist the generated value (false by default). Example: create_table :generated_columns do |t| t.string :name t.virtual :upper_name, type: :string, as: "UPPER(name)" t.virtual :name_length, type: :integer, as: "LENGTH(name)", stored: true t.index :name_length # May be indexed, too! end Closes #22589
* | Optimizing information_schema query for `foreign_keys`Ryuta Kamizono2017-01-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Need `table_name` to avoid all databases scan. See https://dev.mysql.com/doc/refman/5.7/en/information-schema-optimization.html. ``` > EXPLAIN SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key', fk.column_name AS 'column', fk.constraint_name AS 'name', rc.update_rule AS 'on_update', rc.delete_rule AS 'on_delete' FROM information_schema.key_column_usage fk JOIN information_schema.referential_constraints rc USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'activerecord_unittest' AND fk.table_name = 'fk_test_has_pk' AND rc.table_name = 'fk_test_has_pk'\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: fk partitions: NULL type: ALL possible_keys: NULL key: TABLE_SCHEMA,TABLE_NAME key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: Using where; Open_full_table; Scanned 0 databases *************************** 2. row *************************** id: 1 select_type: SIMPLE table: rc partitions: NULL type: ALL possible_keys: NULL key: TABLE_NAME key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: Using where; Open_full_table; Scanned 1 database; Using join buffer (Block Nested Loop) 2 rows in set, 1 warning (0.00 sec) ``` Fixes #27579.
* | Deprecate passing `name` to `indexes` like `tables`Ryuta Kamizono2017-01-041-0/+6
| | | | | | | | | | Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
* | Merge pull request #27435 from kamipo/follow_up_25307Sean Griffin2017-01-031-2/+2
|\ \ | | | | | | Active Record supports MySQL >= 5.1.10
| * | Active Record supports MySQL >= 5.1.10Ryuta Kamizono2016-12-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up to #25307 and #23458. Related with #27422. We are using `information_schema.referential_constraints` since #25307. The table was introduced in MySQL 5.1.10. MySQL 5.0 is too old. It is enough to support >= 5.1.10 at least. MySQL 5.0 GA was released in Dec 2005 and already EOL in Dec 2011. MySQL 5.1 GA was released in Dec 2008 and already EOL in Dec 2013.
* | | Revert "Merge pull request #27528 from kamipo/extract_casted_booleans"Kasper Timm Hansen2017-01-011-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As pointed out by @matthewd this change makes ImmutableString aware of MysqlString's existence whereas previously MysqlString was only overriding public API. cc @kamipo This reverts commit e632c2fa4cb60072a778ce95c952a0fa95e5b074, reversing changes made to 334a7dcf107cd3ff1697163d331d289d6d65dcd7.
* | | Extract `casted_true`/`casted_false` for `Type::ImmutableString`Ryuta Kamizono2017-01-011-14/+6
| | | | | | | | | | | | | | | | | | The only difference between `Type::ImmutableString` and its subclasses is the representation of the casted booleans. Prefer extracting `casted_true`/`casted_false` and override these by subclasses.
* | | `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-291-23/+20
| | |
* | | Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-291-7/+1
| | |
* | | Merge pull request #27402 from yui-knk/executeRafael França2016-12-281-1/+1
|\ \ \ | | | | | | | | Use `#execute` instead of `@connection.query`
| * | | Use `#execute` instead of `@connection.query`yui-knk2016-12-191-1/+1
| |/ / | | | | | | | | | | | | `@connection.query` bypasses instrumenting "sql.active_record". This behavior preventing us from debugging SQLs which Rails generates.
* | / Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-281-14/+14
| |/ |/| | | | | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* | Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-241-19/+17
|/
* Merge pull request #25227 from kamipo/numeric_value_out_of_rangeSean Griffin2016-12-101-0/+3
|\ | | | | Translate numeric value out of range to the specific exception
| * Translate numeric value out of range to the specific exceptionRyuta Kamizono2016-12-061-0/+3
| | | | | | | | Raise `ActiveRecord::RangeError` when values that executed are out of range.
* | Merge pull request #27278 from kamipo/should_be_sync_primary_key_definitionSean Griffin2016-12-081-1/+1
|\ \ | |/ |/| Should be sync the `primary_key` definition with actually created
| * Should be sync the `primary_key` definition with actually createdRyuta Kamizono2016-12-061-1/+1
| | | | | | | | | | | | | | | | Actually the `primary_key` definition is not used but the inconsistency is confusing. Actual definition is `bigint auto_increment PRIMARY KEY` so `UNSIGNED` and `(8)` is unnecessary. See also #21607.
* | Translate NOT NULL violation to the specific exceptionRyuta Kamizono2016-12-061-0/+4
| | | | | | | | | | Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted or updated because it would violate a not null constraint.
* | Merge pull request #26687 from kamipo/fix_add_index_to_normalize_optionsMatthew Draper2016-12-061-0/+1
|\ \ | |/ |/| Fix `add_index` to normalize column names and options
| * Fix `add_index` to normalize column names and optionsRyuta Kamizono2016-10-031-0/+1
| | | | | | | | | | | | | | | | | | | | Currently does not work the following code. ```ruby add_index(:people, ["last_name", "first_name"], order: { last_name: :desc, first_name: :asc }) ``` Normalize column names and options to fix the issue.
* | Make pg adapter use bigserial for pk by defaultPavel Pravosud2016-12-051-1/+23
| |
* | Change MySQL and Postgresql to use Bigint primary keysJon McCartie2016-12-051-1/+1
| |
* | Fix that `change_column` lose a commentRyuta Kamizono2016-12-051-0/+4
| |
* | Fix that unsigned with zerofill is treated as signedRyuta Kamizono2016-11-271-1/+1
| | | | | | | | Fixes #27125.
* | Refactor column initialization into `new_column_from_field`Kir Shatrov2016-11-111-11/+7
| | | | | | | | that accepts results of SHOW FIELDS
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
| |
* | Permit loads while queries are runningMatthew Draper2016-10-271-1/+5
| | | | | | | | | | A query may wait on a database-level lock, which could lead to a deadlock between threads.
* | Merge pull request #26899 from kamipo/use_regex_matchXavier Noria2016-10-271-2/+2
|\ \ | | | | | | Use Regexp#match? rather than Regexp#===
| * | Use Regexp#match? rather than Regexp#===Ryuta Kamizono2016-10-261-2/+2
| | | | | | | | | | | | Follow up to 99cf7558000090668b137085bfe6bcc06c4571dc.
* | | let Regexp#match? be globally availableXavier Noria2016-10-271-1/+0
|/ / | | | | | | | | | | Regexp#match? should be considered to be part of the Ruby core library. We are emulating it for < 2.4, but not having to require the extension is part of the illusion of the emulation.
* | Support index.length for MySQL 8.0.0-dmrYasuo Honda2016-10-131-1/+1
| | | | | | | | | | | | | | MySQL 8.0.0-dmr `SUB_PART` column of `information_schema.statistics` changed to varbinary(12), which is bigint(3) in MySQL 5.6. Addresses #26774
* | Dump index options to pretty formatRyuta Kamizono2016-10-101-2/+2
| | | | | | | | | | | | | | | | | | | | ```ruby # Before t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree # After t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree ```
* | Prevent to create blank commentRyuta Kamizono2016-10-081-1/+1
|/ | | | | Currently blank comment does not dump to `db/schema.rb`. But created it even if specified blank.