aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
...
| * 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.
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-2/+2
| | | | | | 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.
* Fix Remaining Case-In-Assignment Statement FormattingAlex Kitchens2016-09-061-16/+17
| | | | | | | | | Recently, the Rails team made an effort to keep the source code consistent, using Ruboco (bb1ecdcc677bf6e68e0252505509c089619b5b90 and below). Some of the case statements were missed. This changes the case statements' formatting and is consistent with changes in 810dff7c9fa9b2a38eb1560ce0378d760529ee6b and db63406cb007ab3756d2a96d2e0b5d4e777f8231.
* Revert "Extract `PredicateBuilder::CaseSensitiveHandler`"Sean Griffin2016-08-311-3/+4
| | | | | | | | | This reverts commit 3a1f6fe7b4a70bf0698b0684dd48ac712c6883b6. This commit takes the code in a direction that I am looking to avoid. The predicate builder should be purely concerned with AST construction as it matters to methods like `where`. Things like case sensitivity should continue to be handled elsewhere.
* Remove text default treated as an empty string in non-strict modeRyuta Kamizono2016-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. If strict mode is not in effect, MySQL inserts adjusted values for invalid or missing values and produces warnings. ```ruby def test_mysql_not_null_defaults_non_strict using_strict(false) do with_mysql_not_null_table do |klass| record = klass.new assert_nil record.non_null_integer assert_nil record.non_null_string assert_nil record.non_null_text assert_nil record.non_null_blob record.save! record.reload assert_equal 0, record.non_null_integer assert_equal "", record.non_null_string assert_equal "", record.non_null_text assert_equal "", record.non_null_blob end end end ``` It is inconsistent with other types that only text/blob defaults treated as an empty string. This commit fixes the inconsistency.
* Merge pull request #25396 from ↵Rafael França2016-08-171-1/+1
|\ | | | | | | | | kamipo/fix_error_message_for_out_of_range_integer_value Fix error message for out of range byte size integer value for consistency
| * Fix error message for out of range byte size integer value for consistencyRyuta Kamizono2016-08-071-1/+1
| | | | | | | | Related f27a932, #25391.
* | Extract `PredicateBuilder::CaseSensitiveHandler`Ryuta Kamizono2016-08-161-4/+3
| | | | | | | | | | | | Currently uniqueness validator is coupled with building Arel ASTs. This commit extracts `PredicateBuilder::CaseSensitiveHandler` for decouple the building Arel ASTs.
* | Merge pull request #26155 from kamipo/refactor_quoted_columns_for_indexRafael Mendonça França2016-08-161-16/+9
|\ \ | | | | | | | | | Refactor `quoted_columns_for_index` by extracted `add_options_for_index_columns`
| * | Refactor `quoted_columns_for_index` by extracted `add_options_for_index_columns`Ryuta Kamizono2016-08-141-16/+9
| |/
* / Add three new rubocop rulesRafael Mendonça França2016-08-161-7/+7
|/ | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Merge pull request #26073 from kamipo/revert_passing_splat_binds_for_arel_nodeSean Griffin2016-08-061-1/+1
|\ | | | | Revert passing arel node with splat binds for `where`
| * Don't passing a nil value to `case_sensitive_comparison`Ryuta Kamizono2016-08-061-1/+1
| | | | | | | | | | A `value` is only used for checking `value.nil?`. It is unnecessary if immediately return when `value.nil?`.
* | applies remaining conventions across the projectXavier Noria2016-08-061-13/+13
| |
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-061-268/+268
| |
* | modernizes hash syntax in activerecordXavier Noria2016-08-061-2/+2
| |
* | applies new string literal convention in activerecord/libXavier Noria2016-08-061-77/+77
|/ | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.