aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
* rails -> Rails [ci skip]Santosh Wadghule2016-07-121-1/+1
|
* [ci skip] Update documentation in AR SchemaStatementsAlex Kitchens2016-07-071-12/+12
| | | | This includes minor grammar fixes throughout the file.
* Merge pull request #25707 from matthewd/double-reapMatthew Draper2016-07-072-10/+39
|\ | | | | Don't reap connections that have already been reassigned
| * Make connection stealing more explicitMatthew Draper2016-07-062-5/+23
| |
| * Reduce locking by taking ownership of stale connectionsMatthew Draper2016-07-061-9/+8
| | | | | | | | | | | | This way, we aren't racing other threads, so we don't need to re-check the conditional. And we no longer need to hold the lock while calling remove (which can choose to make a new connection while we wait).
| * Re-check that the connection is still stale before we reap itMatthew Draper2016-07-061-0/+2
| | | | | | | | | | | | | | A concurrent thread may have also detected it to be stale, and already released (or even reassigned) it by now. Fixes #25585
| * Check connection ownership before allowing a thread to release itMatthew Draper2016-07-061-1/+11
| | | | | | | | | | A thread can only release a connection if it owns it, or it's owned by a thread that has died.
* | [ci skip] Update ConnectionPool documentation for readabilityAlex Kitchens2016-07-061-21/+21
|/
* Merge pull request #25507 from ↵Rafael França2016-07-021-13/+0
|\ | | | | | | | | bquorning/optimize-for-first-result-and-remove-mysql-select_one Remove #select_one from Mysql2Adapter
| * Remove MySQL::DatabaseStatements#select_oneBenjamin Quorning2016-06-241-13/+0
| | | | | | | | | | | | | | | | The implementation from abstract/database_statements.rb seems to work just fine. And with ActiveRecord::Result now implementing an optimized #first method, the performance concerns previously addressed in https://github.com/rails/rails/commit/bf79aa4fc14aeb2646331e767038acf0b77e9e7f should not be an issue.
* | Remove `create_table_info_cache` because it not be reusedRyuta Kamizono2016-07-021-6/+1
| | | | | | | | | | | | `create_table_info_cache` is used for sharing `create_table_info` both `table_options` and `foreign_keys`. But `foreign_keys` no longer uses `create_table_info_cache` by #25307. No need caching anymore.
* | Merge pull request #25307 from ↵Eileen M. Uchitelle2016-07-012-17/+17
|\ \ | | | | | | | | | | | | kamipo/extract_foreign_key_action_from_information_schema Extract foreign key action from `information_schema`
| * | Extract foreign key action from `information_schema`Ryuta Kamizono2016-06-071-15/+15
| | | | | | | | | | | | Fixes #25300.
| * | Make `foreign_keys` queries to `SCHEMA`Ryuta Kamizono2016-06-072-2/+2
| | |
* | | Remove unnecessary `assert_valid_default`Ryuta Kamizono2016-06-251-7/+0
| |/ |/| | | | | | | This was added at c7c3f73 but it never raised because MySQL cannot create text/blob columns with a default value.
* | Merge pull request #25339 from prathamesh-sonpatki/reuse-validate-index-lengthRafael França2016-06-151-7/+7
|\ \ | | | | | | Reuse validate index length
| * | Reuse existing validate_index_length! methodPrathamesh Sonpatki2016-06-091-7/+7
| |/ | | | | | | - Followup of https://github.com/rails/rails/commit/1ea6cc11211dc89e3e14b2b641a3cca8a0a91d55.
* / Fix error message to talk about the scale not precision of the typeRafael Mendonça França2016-06-131-1/+1
|/ | | | Fixes #25391
* Fix failing testsSean Griffin2016-06-021-4/+5
| | | | | | | | | | | | | | | | | | | Currently CI is broken due to 56a61e0 and c4cb686. This occurred because the failures are not present on SQLite which is what I normally run locally before pushing. The optimizations to our YAML size were dropping mutations, as `with_type` didn't set the previous value if it'd already been read (that method was never really designed to be used with values on individual objects, it was previously only used for defaults). I'm questioning whether there's a better place to be handling the exclusion of the type, but this will fix the failing build. Additionally, there was a bug in `remove_foreign_key` if you passed it an options hash containing `to_table`. This now occurs whenever removing a reference, as we always normalize to a hash. [Sean Griffin & Ryuta Kamizono]
* Respect options passed to `foreign_key` when reverting `add_reference`Sean Griffin2016-05-311-4/+9
| | | | | | | | | | | | The code incorrectly assumes that the option was written as `foreign_key: true`, but that is not always the case. This now mirrors the behavior of reverting `add_foreign_key`. The code was changed to use kwargs while I was touching it, as well. This could really use a refactoring to go through the same code paths as `add_refernce` in the future, so we don't duplicate default values. Fixes #25169
* Do not include default column limit in schema.rbRyuta Kamizono2016-05-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up of #20815. ```ruby class CreatePeople < ActiveRecord::Migration[5.0] def change create_table :people do |t| t.integer :int t.bigint :bint t.text :txt t.binary :bin end end end ``` Result. In postgresql and sqlite3 adapters: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade do |t| t.integer "int" t.bigint "bint" t.text "txt" t.binary "bin" end end ``` In mysql2 adapter: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t| t.integer "int" t.bigint "bint" t.text "txt", limit: 65535 t.binary "bin", limit: 65535 end end ``` After this patch: ```ruby ActiveRecord::Schema.define(version: 20160531141018) do create_table "people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t| t.integer "int" t.bigint "bint" t.text "txt" t.binary "bin" end end ```
* Add to_hash to specificationArthur Neves2016-05-252-2/+5
|
* Remove `name` from `establish_connection`Arthur Neves2016-05-242-19/+10
| | | | | Instead of passing a separete name variable, we can make the resolver merge a name on the config, and use that before creating the Specification.
* Move establish_connection to handlerArthur Neves2016-05-242-1/+13
|
* Add AR::TransactionSerializationError for transaction serialization failures ↵Erol Fornoles2016-05-212-3/+14
| | | | or deadlocks
* [ci skip] Update retrieve_connection_pool commentBenjamin Quorning2016-05-201-7/+1
| | | | | | | | | After PR https://github.com/rails/rails/pull/24844 the documentation for `#retrieve_connection_pool` was out of date. This commit changes: - the reference from `@class_to_pool` to `@owner_to_pool`. - with newer Rubies, `#fetch` isn't significantly slower than `#[]`. Since Rails 5 requires Ruby >= 2.2.2, we can just use `#fetch` here.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-2/+2
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Rails 5.1 point type should not raise exception if empty string is provided ↵bUg2016-05-151-0/+2
| | | | as value
* [ci skip] Update documents of `ConnectionHandler`yui-knk2016-05-111-3/+1
| | | | | | | | Follow up of #24844. The key of `@owner_to_pool` was changed from `klass.name` to `spec.name`. By this change "memory leaks in development mode" will not happen, bacause the equality of string is not changed by reloading of model files.
* Should quote `lock_name` to pass to `get_advisory_lock`Ryuta Kamizono2016-05-101-2/+2
|
* Replacement cycle for readabilityMolchanov Andrey2016-05-091-2/+2
|
* Followup to #24844Jon Moss2016-05-071-0/+2
| | | | | | | Some slight documentation edits and fixes. Also, run remove unnecessary `RuntimeError`. r? @arthurnn
* Merge pull request #24844 from arthurnn/arthurnn/connArthur Nogueira Neves2016-05-062-52/+41
|\ | | | | Refactor connection handler
| * Update docs for connection handlerArthur Neves2016-05-061-2/+5
| | | | | | | | [skip ci]
| * s/specification_id/specification_nameArthur Neves2016-05-052-22/+22
| |
| * inline retrive_conn_pool methodArthur Neves2016-05-051-12/+8
| |
| * Better code readabilityArthur Neves2016-05-051-1/+1
| |
| * Use spec key, when given as spec_idArthur Neves2016-05-051-1/+8
| |
| * Refactor connection handlerArthur Neves2016-05-052-42/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ConnectionHandler will not have any knowlodge of AR models now, it will only know about the specs. Like that we can decouple the two, and allow the same model to use more than one connection. Historically, folks used to create abstract AR classes on the fly in order to have multiple connections for the same model, and override the connection methods. With this, now we can override the `specificiation_id` method in the model, to return a key, that will be used to find the connection_pool from the handler.
* | Allow the connection adapters to determine the order of bind paramsSean Griffin2016-05-061-0/+18
|/ | | | | | | | | | | | In 5.0 we use bind parameters for limit and offset, while in 4.2 we used the values directly. The code as it was written assumed that limit and offset worked as `LIMIT ? OFFSET ?`. Both Oracle and SQL Server have a different syntax, where the offset is stated before the limit. We delegate this behavior to the connection adapter so that these adapters are able to determine how the bind parameters are flattened based on what order their specification has the various clauses appear. Fixes #24775
* Fix some typos in comments.Joe Rafaniello2016-05-041-1/+1
| | | | [ci skip]
* Add `:nodoc:` to `schema_creation` [ci skip]Ryuta Kamizono2016-05-021-1/+1
| | | | | | | `schema_creation` is not public API. https://github.com/rails/rails/blob/v5.0.0.beta4/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L121 https://github.com/rails/rails/blob/v5.0.0.beta4/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L78
* Extract `add_sql_comment!` methodRyuta Kamizono2016-04-292-17/+10
| | | | | | Refactor of #22911. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Treat blank comments as no comment for indexesRyuta Kamizono2016-04-292-5/+1
| | | | | | Follow up of 1683410. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Merge pull request #24730 from vipulnsward/move-savepointsRafael França2016-04-252-4/+4
|\ | | | | Move remaining current_savepoint_name to savepoints module
| * Move remaining current_savepoint_name to savepoints moduleVipul A M2016-04-252-4/+4
| |
* | Dont simply assume a type is a valid database type. This is only always true ↵Vipul A M2016-04-252-1/+5
|/ | | | | | | in the case of sqlite. Others adapters need to perform a check for validity. Add coverage for mysql2 db type validation
* Add Expression Indexes and Operator Classes support for PostgreSQLRyuta Kamizono2016-04-244-18/+46
| | | | | | | | | | | | | | | | Example: create_table :users do |t| t.string :name t.index 'lower(name) varchar_pattern_ops' end Fixes #19090. Fixes #21765. Fixes #21819. Fixes #24359. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* remove_index do not fetch indexes if name is specifiedSeva Orlov2016-04-241-1/+7
| | | | | | There is no need to fetch all table indexes in remove_index if name is specified. If name is wrong, then StatementInvalid will be raised. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Follow up of #23461Vipul A M2016-04-244-6/+8
| | | | | | | | - Rename max to statement_limit - Remove magic number 1000 from everywhere - Defined StatementPool::DEFAULT_STATEMENT_LIMIT and started using it everywhere Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>