aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* Simplify the regex for `unsigned?` methodRyuta Kamizono2016-12-111-2/+1
| | | | | It is enough to distinguish only the trailing `unsigned` and `unsigned zerofill`.
* Merge pull request #25227 from kamipo/numeric_value_out_of_rangeSean Griffin2016-12-102-0/+6
|\ | | | | Translate numeric value out of range to the specific exception
| * Translate numeric value out of range to the specific exceptionRyuta Kamizono2016-12-062-0/+6
| | | | | | | | 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.
* | | [ci skip] Document regex changeAlex Kitchens2016-12-061-0/+1
| |/ |/|
* | Translate NOT NULL violation to the specific exceptionRyuta Kamizono2016-12-063-0/+9
| | | | | | | | | | 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-062-0/+2
|\ \ | |/ |/| Fix `add_index` to normalize column names and options
| * Fix `add_index` to normalize column names and optionsRyuta Kamizono2016-10-032-1/+3
| | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #27274 from kamipo/primary_key_with_auto_increment_and_bigintMatthew Draper2016-12-062-3/+7
|\ \ | | | | | | Make `:auto_increment` option works on `:bigint`
| * | Make `:auto_increment` option works on `:bigint`Ryuta Kamizono2016-12-062-3/+7
| | | | | | | | | | | | Follow up to #27272.
* | | 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-059-11/+27
|/ /
* | Make `:auto_increment` to internal primary key optionRyuta Kamizono2016-12-063-1/+38
| | | | | | | | | | | | Using `:auto_increment` option for abstracting the DB-specific auto incremental types. It is worth to ease to implement the compatibility layer.
* | Don't try to run multiple insert queries at onceSean Griffin2016-12-051-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | SQLite's default query interface ignores anything after the first semicolon in a query. This is actually quite common behavior in database drivers, especially when dealing with code paths for prepared statements (which we are). While this should only affect SQLite, as I'm not aware of any drivers which don't support multi-insert. Even if this does affect other third party drivers though, I'd prefer not to assume that more than one query can be executed per call to `execute`. Fixes #26948. Close #27242.
* | Fix that `change_column` lose a commentRyuta Kamizono2016-12-051-0/+4
| |
* | Stop using the `pg` Float encoderSean Griffin2016-12-011-1/+0
| | | | | | | | | | | | | | | | | | | | PG's type map assumes that all Ruby floats are going to a field with an OID of type float4 or float8, and generates text which is invalid syntax for other types. Since the gem can handle floats properly without this encoder (albeit slightly slower), we can continue to use that as we have in prior versions of Rails. Fixes #27246
* | Fix that unsigned with zerofill is treated as signedRyuta Kamizono2016-11-272-2/+2
| | | | | | | | Fixes #27125.
* | 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