aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Clear available connections immediatelyMatthew Draper2016-11-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It'll be re-cleared when it's rebuilt in with_new_connections_blocked's ensure, but we still need to clear it inside this synchronize -- we've disconnected connections that may be available in the queue, and while other threads are not allowed to make *new* connections, they are still allowed to take existing ones from there. This was incorrectly removed in d314646c965b045724e6bdb9d61dcecfabc0ba8f.
* | | Merge pull request #27165 from ↵Rafael França2016-11-251-5/+15
|\ \ \ | | | | | | | | | | | | | | | | prathamesh-sonpatki/followup-uuid-extension-change Followup of UUID default extension in the docs
| * | | Followup of UUID default extension in the docs [ci skip]Prathamesh Sonpatki2016-11-241-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Mentioned clearly that for PostgreSQL < 9.4, you need to pass the default option with "uuid_generate_v4()" - Also updated PostgreSQL Active Record guide with this change. - https://github.com/rails/rails/pull/25395#r66877078
* | | | Merge pull request #27108 from matthewd/allocate-connections-after-blockingMatthew Draper2016-11-251-19/+17
|\ \ \ \ | |/ / / |/| | | Distribute connections to previously blocked threads when we're done
| * | | Distribute connections to previously blocked threads when we're doneMatthew Draper2016-11-251-19/+17
| | |/ | |/| | | | | | | | | | | | | Two methods block new connections; we were already doing the right thing for clear_reloadable_connections, but it's better placed in with_new_connections_blocked, where it can work for disconnect too.
* / | For `PostgreSQL >= 9.4` use `gen_random_uuid()`Yaw Boakye2016-11-222-8/+13
|/ / | | | | | | | | | | | | | | | | | | Since 9.4, PostgreSQL recommends using `pgcrypto`'s `gen_random_uuid()` to generate version 4 UUIDs instead of the functions in the `uuid-ossp` extension. These changes uses the appropriate UUID function depending on the underlying PostgreSQL server's version, while maintaining `uuid_generate_v4()` in older migrations.
* | Merge pull request #27057 from kamipo/fix_race_conditionMatthew Draper2016-11-191-6/+7
|\ \ | | | | | | | | | Fix the race condition caused by `with_new_connections_blocked`
| * | Fix the race condition caused by `with_new_connections_blocked`Ryuta Kamizono2016-11-181-8/+4
| | | | | | | | | | | | | | | | | | `with_new_connections_blocked` was introduced at #14938. But the method sometimes causes `@new_cons_enabled = false` then never toggled to true.
* | | Merge pull request #27076 from y-yagi/fix_postgresql_array_encodingSean Griffin2016-11-171-1/+1
|\ \ \ | | | | | | | | use `force_encoding` instread of `encode!` to avoid `UndefinedConversionError`
| * | | use `force_encoding` instread of `encode!` to avoid `UndefinedConversionError`yuuji.yaginuma2016-11-171-1/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `PG::TextEncoder::Array#encode` returns the encoded value with `ASCII-8BIT`. But in some cases, trying to convert `ASCII-8BIT` to `UTF-8` cause an error. ```ruby "{\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB}".encode!(Encoding::UTF_8) # => Encoding::UndefinedConversionError: "\xE3" from ASCII-8BIT to UTF-8 ``` Should use `force_encoding` to avoid this error. Follow up to 7ba3a48df5bfdc5e98506bb829f937e03b55a5b3 Ref: https://github.com/rails/rails/pull/23619#issuecomment-189924036
* / / Support AC::Parameters for PG HStoreJon Moss2016-11-151-0/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | As reported via #26904, there is a regression in how values for Postgres' HStore column type are being processed, beginning in Rails 5. Currently, the way that Active Record checks whether or not values need to be serialized and put into the correct storage format is whether or not it is a `Hash` object. Since `ActionController::Parameters` no longer inherits from `Hash` in Rails 5, this conditional now returns false. To remedy this, we are now checking to see whether the `value` parameters being passed in responds to a certain method, and then calling the `serialize` method, except this time with a real Hash object. Keeping things DRY! Fixes #26904.
* | Fix NameError: undefined local variable or method `result`Ryuta Kamizono2016-11-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Caused by 007e50d8e5a900547471b6c4ec79d9d217682c5d. https://github.com/rails/rails/pull/26925 was closed in favor of dcb364e. But dcb364e is only fixed sqlite3 adapter and still broken mysql2 adapter with `prepared_statements: true` (`exec_stmt_and_free`). ```diff diff --git a/activerecord/test/config.example.yml b/activerecord/test/config.example.yml index 58e2d45..7b3c1a6 100644 --- a/activerecord/test/config.example.yml +++ b/activerecord/test/config.example.yml @@ -56,9 +56,11 @@ connections: username: rails encoding: utf8 collation: utf8_unicode_ci + prepared_statements: true arunit2: username: rails encoding: utf8 + prepared_statements: true oracle: arunit: ``` ``` % be rake test_mysql2 --verbose ... Using mysql2 /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb:90: warning: assigned but unused variable - result /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb:101:in `block in exec_stmt_and_free': NameError: undefined local variable or method `result' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007fe2c50eb140>: SELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = ? LIMIT ? (ActiveRecord::StatementInvalid) from /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:586:in `block in log' ... ```
* | Merge pull request #26905 from bogdanvlviv/docsAndrew White2016-11-134-9/+9
|\ \ | | | | | | Add missing `+` around a some literals.
| * | Add missing `+` around a some literals.bogdanvlviv2016-10-274-9/+9
| | | | | | | | | | | | | | | | | | Mainly around `nil` [ci skip]
* | | Add `:nodoc` to `table_structure`Ryuta Kamizono2016-11-121-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | Follow up to #27008. `table_structure` is an internal method so it is better to hide it in the doc. And alias `table_structure` to `column_definitions` to remove the duplicated `columns` method in the sqlite3 adapter.
* | | Refactor column initialization into `new_column_from_field`Kir Shatrov2016-11-114-38/+48
| | | | | | | | | | | | that accepts results of SHOW FIELDS
* | | Merge pull request #26978 from matthewd/query-cache-poolMatthew Draper2016-11-102-0/+28
|\ \ \ | | | | | | | | Configure query caching (per thread) on the connection pool
| * | | Configure query caching (per thread) on the connection poolMatthew Draper2016-11-062-0/+28
| | | |
* | | | Mysql2::Client::FOUND_ROWS should be defined in all currently supported ↵Akira Matsuda2016-11-101-6/+4
| | | | | | | | | | | | | | | | versions of mysql2
* | | | Add ActiveRecord::Base.connection_pool.statPavel2016-11-091-0/+18
|/ / /
* | | Merge pull request #26909 from matthewd/query-cache-connectionMatthew Draper2016-11-062-3/+5
|\ \ \ | | | | | | | | Clear query cache during checkin, instead of an execution callback
| * | | Clear query cache during checkin, instead of an execution callbackMatthew Draper2016-10-272-3/+5
| |/ / | | | | | | | | | | | | | | | | | | It doesn't make sense for the query cache to persist while a connection moves through the pool and is assigned to a new thread. [Samuel Cochran & Matthew Draper]
* | | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-2910-17/+17
| | |
* | | Fix the variable scoping issue I introduced in ↵Matthew Draper2016-10-281-2/+2
| | | | | | | | | | | | 007e50d8e5a900547471b6c4ec79d9d217682c5d
* | | Merge pull request #26688 from kamipo/remove_respond_to_indexesKasper Timm Hansen2016-10-281-4/+0
|\ \ \ | | | | | | | | Remove unnecessary `respond_to?(:indexes)` checking
| * | | Remove unnecessary `respond_to?(:indexes)` checkingRyuta Kamizono2016-10-031-4/+0
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | Currently all adapters (postgresql, mysql2, sqlite3, oracle-enhanced, and sqlserver) implemented `indexes` and schema dumper expects implemented `indexes`. https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/schema_dumper.rb#L208 Therefore `respond_to?(:indexes)` checking is unnecessary.
* | | Permit loads while queries are runningMatthew Draper2016-10-275-25/+47
| | | | | | | | | | | | | | | 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-277-10/+10
|\ \ \ | | | | | | | | Use Regexp#match? rather than Regexp#===
| * | | Use Regexp#match? rather than Regexp#===Ryuta Kamizono2016-10-267-10/+10
| | |/ | |/| | | | | | | 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.
* | Fix indentation of code examplesOrhan Toy2016-10-191-4/+4
| | | | | | | | This commit fixes the generated HTML of the two code examples.
* | Merge pull request #26784 from kamipo/quote_table_name_properlyRafael França2016-10-143-13/+15
|\ \ | | | | | | Quote table name properly
| * | Quote table name properlyRyuta Kamizono2016-10-143-13/+15
| | | | | | | | | | | | If does not quote table name properly, invalid SQL is generated.
* | | 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
* | Merge pull request #26208 from nanaya/pg-insensitive-textMatthew Draper2016-10-111-2/+6
|\ \ | | | | | | | | | Fix case insensitive check for text column in pg
| * | Fix case insensitive check for text column in pgnanaya2016-09-011-0/+4
| | | | | | | | | | | | There's no 'text to text' casting in the cast table so the feature detection fails.
| * | Use proper castingnanaya2016-09-011-2/+2
| | |
* | | Extract `format_colspec` to format column specRyuta Kamizono2016-10-111-3/+1
| | |
* | | Fix table comment dumpingRyuta Kamizono2016-10-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up to #26735. If `table_options` returns `{ comment: nil }`, `create_table` line is broken. Example: ```ruby create_table "accounts", force: :cascade, do |t| ```
* | | `name` is not a column optionRyuta Kamizono2016-10-102-3/+2
| | | | | | | | | | | | `migration_keys` includes `name` but `name` is not a column option.
* | | Dump index options to pretty formatRyuta Kamizono2016-10-102-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ```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-082-3/+3
| |/ |/| | | | | | | Currently blank comment does not dump to `db/schema.rb`. But created it even if specified blank.
* | Merge pull request #26584 from Shopify/cached-query-nameRafael França2016-09-301-4/+10
|\ \ | | | | | | Preserve cached queries name in AS notifications
| * | Preserve cached queries name in AS notificationsJean Boussier2016-09-221-4/+10
| | |
* | | [ci skip] Update PG adapter documentationAlex Kitchens2016-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Per discussion in pull request #26622: "Let's change it to PG::Error. The more specific classes mentioned are subclasses, and the fact the raised exception is a PG::UndefinedColumn doesn't change the fact that it's also a PG::Error." - matthewd
* | | [ci skip] Clarify Postgresql DocumentationAlex Kitchens2016-09-251-4/+4
|/ / | | | | | | | | This clarifies the object that +ActiveRecord::Base.connection.execute+ will return when using Postgresql.
* | Force correct namespace when using TransactionManagerArthur Neves2016-09-161-1/+1
| | | | | | | | [fixes #26441]
* | fix typo in `add_column` doc [ci skip]yuuji.yaginuma2016-09-161-1/+1
| |
* | Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-145-96/+96
| | | | | | | | | | | | 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.
* | activerecord/mysql2: Avoid setting @connection to nil, just close itDylan Thacker-Smith2016-09-082-15/+7
| | | | | | | | | | | | | | | | | | | | 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.