aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Omit the default limit for float columns (#28041)Ryuta Kamizono2017-08-271-1/+1
|
* Merge pull request #30337 from kamipo/refactor_schema_dumperRyuta Kamizono2017-08-241-1/+0
|\ | | | | Refactor `SchemaDumper` to make it possible to adapter specific customization
| * Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-221-1/+0
| | | | | | | | | | | | | | Currently `SchemaDumper` is only customizable for column options. But 3rd party connection adapters (oracle-enhanced etc) need to customizable for table or index dumping also. To make it possible, I introduced adapter specific `SchemaDumper` classes for that.
* | Merge pull request #30360 from gcourtemanche/transaction_timedoutRafael França2017-08-221-0/+3
|\ \ | |/ |/| Add TransactionTimeout for MySQL error code 1205
| * Add TransactionTimeout for MySQL error code 1205Gabriel Courtemanche2017-08-221-0/+3
| |
* | Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-221-2/+2
|/
* Place `update_table_definition` consistently in `SchemaStatements`Ryuta Kamizono2017-08-211-4/+0
|
* Restore `to_sql` to return only SQL (#29945)Ryuta Kamizono2017-08-181-2/+1
| | | | Because `to_sql` is public API. I introduced `to_sql_and_binds` internal API to return SQL and binds.
* Use `predicate_builder.build_bind_attribute` wherever possibleRyuta Kamizono2017-07-281-1/+1
| | | | For less duplicated code.
* Fix build failures on MySQLSean Griffin2017-07-241-1/+1
| | | | | | There's an actual bug in 213796fb4936dce1da2f0c097a054e1af5c25c2c around prepared statements being disabled. I'm looking into it, but in the mean time this gets the build green so it doesn't block other PRs
* Refactor Active Record to let Arel manage bind paramsSean Griffin2017-07-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common source of bugs and code bloat within Active Record has been the need for us to maintain the list of bind values separately from the AST they're associated with. This makes any sort of AST manipulation incredibly difficult, as any time we want to potentially insert or remove an AST node, we need to traverse the entire tree to find where the associated bind parameters are. With this change, the bind parameters now live on the AST directly. Active Record does not need to know or care about them until the final AST traversal for SQL construction. Rather than returning just the SQL, the Arel collector will now return both the SQL and the bind parameters. At this point the connection adapter will have all the values that it had before. A bit of this code is janky and something I'd like to refactor later. In particular, I don't like how we're handling associations in the predicate builder, the special casing of `StatementCache::Substitute` in `QueryAttribute`, or generally how we're handling bind value replacement in the statement cache when prepared statements are disabled. This also mostly reverts #26378, as it moved all the code into a location that I wanted to delete. /cc @metaskills @yahonda, this change will affect the adapters Fixes #29766. Fixes #29804. Fixes #26541. Close #28539. Close #24769. Close #26468. Close #26202. There are probably other issues/PRs that can be closed because of this commit, but that's all I could find on the first few pages.
* Merge pull request #29870 from kamipo/use_true_false_literalsSean Griffin2017-07-221-4/+4
|\ | | | | Use `TRUE` and `FALSE` boolean literals for MySQL
| * Use `TRUE` and `FALSE` boolean literals for MySQLRyuta Kamizono2017-07-201-4/+6
| | | | | | | | | | | | Since #29699, abstract boolean serialization has been changed to use `TRUE` and `FALSE` literals. MySQL also support the literals. So we can use the abstract boolean serialization even for MySQL.
* | Merge pull request #29869 from kamipo/make_type_map_to_privateRafael França2017-07-211-1/+1
|\ \ | | | | | | Make `type_map` to private because it is only used in the connection adapter
| * | Make `type_map` to private because it is only used in the connection adapterRyuta Kamizono2017-07-201-1/+1
| |/ | | | | | | | | | | | | `type_map` is an internal API and it is only used in the connection adapter. And also, some type map initializer methods requires passed `type_map`, but those instances already has `type_map` in itself. So we don't need explicit passing `type_map` to the initializers.
* / Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|/
* Fix extracting MariaDB versionRyuta Kamizono2017-07-071-2/+6
| | | | | | Currently `version` method always returns `5.5.5` because the `full_version` is `5.5.5-10.x.y-MariaDB...` since MariaDB 10.x. It should be ignored if the prefix is `5.5.5-`.
* Remove database specific JSON typesRyuta Kamizono2017-07-051-3/+0
| | | | We already have database agnostic `Type::Json` since #29220.
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-14/+14
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| | |
| * | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-021-4/+4
| |\ \ | | | | | | | | | | | | Make ActiveSupport frozen-string-literal friendly.
| | * | Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-201-4/+4
| | | |
| * | | Don't cache queries for schema statementsRyuta Kamizono2017-06-301-10/+10
| | |/ | |/| | | | | | | | | | | | | `test_middleware_caches` is sometimes failed since #29454. The failure is due to schema statements are affected by query caching. Bypassing query caching for schema statements to avoid the issue.
* / | [Active Record] require => require_relativeAkira Matsuda2017-07-011-10/+10
|/ /
* | Use `quote` method rather than single quotes to identifiers in SQLRyuta Kamizono2017-06-291-1/+1
| | | | | | | | | | | | Because identifiers in SQL could include a single quote. Related #24950, #26784.
* | Use bulk INSERT to insert fixturesKir Shatrov2017-06-201-0/+17
|/ | | | | | | | Improves the performance from O(n) to O(1). Previously it would require 50 queries to insert 50 fixtures. Now it takes only one query. Disabled on sqlite which doesn't support multiple inserts.
* Consolidate database specific JSON types to `Type::Json`Ryuta Kamizono2017-05-301-3/+2
|
* Deserialize a raw value from the database in `changed_in_place?` for ↵Ryuta Kamizono2017-05-301-5/+0
| | | | | | | | `AbstractJson` Structured type values sometimes caused representation problems (keys sort order, spaces, etc). A raw value from the database should be deserialized (normalized) to prevent the problems.
* Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-2/+1
| | | | | | | | | | | | * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
* Don't pass `arel.engine` to `Arel::SelectManager.new`Ryuta Kamizono2017-05-051-6/+4
| | | | | | The argument of `Arel::SelectManager.new` is `table`, not `engine`. https://github.com/rails/arel/blob/v8.0.0/lib/arel/select_manager.rb#L10
* Deprecate `supports_statement_cache?`Ryuta Kamizono2017-05-011-6/+0
| | | | | | | | | | | | | | `supports_statement_cache?` was introduced in 3.1.0.beta1 (104d0b2) for bind parameter substitution, but it is no longer used in 3.1.0.rc1 (73ff679). Originally it should respect `prepared_statements` rather than `supports_statement_cache?` (fd39847). One more thing, named `supports_statement_cache?` is pretty misreading. We have `StatementCache` and `StatementPool`. However, `supports_statement_cache?` doesn't mean `StatementCache`, but `StatementPool` unlike its name. https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/statement_cache.rb https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/connection_adapters/statement_pool.rb
* Don't fallback to utf8mb3 after MySQL 8.0.0Ryuta Kamizono2017-04-171-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `internal_string_options_for_primary_key` is used for creating internal tables in newly apps. But it is no longer needed after MySQL 8.0.0. MySQL 5.7 has introduced `innodb_default_row_format` (default `DYNAMIC`) and has deprecated `innodb_large_prefix` and `innodb_file_format`. The purpose of the deprecated options was for compatibility with earlier versions of InnoDB. https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_large_prefix > innodb_large_prefix is deprecated and will be removed in a future release. innodb_large_prefix was introduced in MySQL 5.5 to disable large index key prefixes for compatibility with earlier versions of InnoDB that do not support large index key prefixes. https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_file_format > The innodb_file_format option is deprecated and will be removed in a future release. The purpose of the innodb_file_format option was to allow users to downgrade to the built-in version of InnoDB in MySQL 5.1. Now that MySQL 5.1 has reached the end of its product lifecycle, downgrade support provided by this option is no longer necessary. The deprecated options has removed in MySQL 8.0.0. It is no longer needed to take care newly created internal tables as a legacy format after MySQL 8.0.0. Fixes #28730.
* 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.