aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract
Commit message (Collapse)AuthorAgeFilesLines
* Make connection stealing more explicitMatthew Draper2016-07-061-4/+9
|
* 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
* Reuse existing validate_index_length! methodPrathamesh Sonpatki2016-06-091-7/+7
| | | | - Followup of https://github.com/rails/rails/commit/1ea6cc11211dc89e3e14b2b641a3cca8a0a91d55.
* 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
* Add to_hash to specificationArthur Neves2016-05-251-2/+1
|
* Remove `name` from `establish_connection`Arthur Neves2016-05-241-10/+7
| | | | | 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-241-1/+9
|
* [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.
* [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.
* 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
* Update docs for connection handlerArthur Neves2016-05-061-2/+5
| | | | [skip ci]
* s/specification_id/specification_nameArthur Neves2016-05-051-16/+16
|
* inline retrive_conn_pool methodArthur Neves2016-05-051-12/+8
|
* Refactor connection handlerArthur Neves2016-05-051-37/+20
| | | | | | | | | | | | | | | 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.
* Move remaining current_savepoint_name to savepoints moduleVipul A M2016-04-251-0/+4
|
* Add Expression Indexes and Operator Classes support for PostgreSQLRyuta Kamizono2016-04-241-3/+17
| | | | | | | | | | | | | | | | 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>
* Include the Savepoints module in all adapters.Vipul A M2016-04-242-8/+1
| | | | | Adapters override `#supports_savepoints?` to return `true` if they support transaction savepoints. Defaults to `false`.
* Merge pull request #24708 from ↵Jeremy Daer2016-04-231-1/+1
|\ | | | | | | | | | | kamipo/move_select_rows_implementation_to_super_class Move `select_rows` implementation to super class
| * Move `select_rows` implementation to super classRyuta Kamizono2016-04-241-1/+1
| |
* | Merge pull request #24705 from kamipo/add_nodoc_to_insert_versions_sqlGuillermo Iguaran2016-04-231-1/+1
|\ \ | | | | | | Add `:nodoc:` to `insert_versions_sql` [ci skip]
| * | Add `:nodoc:` to `insert_versions_sql` [ci skip]Ryuta Kamizono2016-04-241-1/+1
| |/ | | | | | | Follow up to #24685. `insert_versions_sql` is not public API.
* / Remove in the doc about MySQL versions below 5 [ci skip]Ryuta Kamizono2016-04-241-3/+1
|/ | | | | Follow up to #23458. Active Record supports MySQL >= 5.0 now.
* Schema load: Fix dupe version insertJeremy Daer2016-04-221-1/+1
| | | | Re. 6e098284e97250eaed6f30f5c7c362d87da986b0
* https://github.com/rails/rails/commit/42dd2336b31a8d98776d039a2b9fd7f834156a ↵Vipul A M2016-04-231-4/+16
| | | | | | | | | 78 changed INSERT INTO versions to run in 1 single query. This breaks for sqlite versions < 3.7.11, which is especially the case on Ubuntu 12.04 LTS, that has SQLite version 3.7.9 as default. So we check for support for multi insert, before performing single query inserts, else fallback to older version of running multiple queries. [Vipul A M & Yasuo Honda]
* Revert "add doc for `:type` option of `#create_join_table` [ci skip]"प्रथमेश Sonpatki2016-04-211-2/+0
|
* add doc for `:type` option of `#create_join_table` [ci skip]yuuji.yaginuma2016-04-211-0/+2
| | | | Follow up to #24221.
* Merge pull request #24221 from gregmolnar/uuidKasper Timm Hansen2016-04-201-2/+3
|\ | | | | create_join_table should work with uuid
| * add column type option to create_join_table to support uuidGreg Molnar2016-03-171-2/+3
| |
* | `undef_method` is not neededRyuta Kamizono2016-04-191-2/+3
| |
* | Database comments: Treat blank comments as no comment. Don't dump blank ↵Jeremy Daer2016-04-191-1/+1
| | | | | | | | comments.
* | `foreign_key` respects `table_name_prefix` and `table_name_suffix`Ryuta Kamizono2016-04-191-0/+3
| |
* | Merge pull request #23622 from kamipo/primary_key_should_be_not_nullJeremy Daer2016-04-181-1/+1
|\ \ | | | | | | | | | Primary key should be `NOT NULL`
| * | Primary key should be `NOT NULL`Ryuta Kamizono2016-03-121-1/+1
| |/ | | | | | | | | | | | | Follow up to #18228. In MySQL and PostgreSQL, primary key is to be `NOT NULL` implicitly. But in SQLite it must be specified `NOT NULL` explicitly.
* | Database comments: switch to keyword args for new table optionsJeremy Daer2016-04-183-23/+24
| | | | | | | | | | | | * Switch to keyword args where we can without breaking compat. * Use add_table_options! for :options, too. * Some code polish.
* | Merge pull request #22911 from Envek/database_commentsJeremy Daer2016-04-164-11/+51
|\ \ | | | | | | | | | Add support for specifying comments for tables, columns, and indexes in database itself
| * | Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-164-11/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Comments are specified in migrations, stored in database itself (in its schema), and dumped into db/schema.rb file. This allows to generate good documentation and explain columns and tables' purpose to everyone from new developers to database administrators. For PostgreSQL and MySQL only. SQLite does not support comments at the moment. See docs for PostgreSQL: http://www.postgresql.org/docs/current/static/sql-comment.html See docs for MySQL: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
* | | documentation for add_references index option [ci skip]Vipul A M2016-04-171-1/+10
|\ \ \ | |/ / |/| | documentation for add_references index option [ci skip]
| * | [ci skip] docs for add_references index optionAlex Handley2016-04-161-1/+10
| | | | | | | | | | | | | | | | | | - Add link for finding the addional options for index. - Add example for unique index as this is a common requirement. - Add link in guide for index options.
* | | Add `quoted_time` for truncating the date part of a time column valueRyuta Kamizono2016-04-141-0/+6
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Context #24522. TIME column on MariaDB doesn't ignore the date part of the string when it coerces to time. ``` root@localhost [test] > CREATE TABLE `foos` (`id` int AUTO_INCREMENT PRIMARY KEY, `start` time(0), `finish` time(4)) ENGINE=InnoDB; Query OK, 0 rows affected (0.02 sec) root@localhost [test] > INSERT INTO `foos` (`start`, `finish`) VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900'); Query OK, 1 row affected, 2 warnings (0.00 sec) Note (Code 1265): Data truncated for column 'start' at row 1 Note (Code 1265): Data truncated for column 'finish' at row 1 root@localhost [test] > SELECT `foos`.* FROM `foos`; +----+----------+---------------+ | id | start | finish | +----+----------+---------------+ | 1 | 12:30:00 | 12:30:00.9999 | +----+----------+---------------+ 1 row in set (0.00 sec) root@localhost [test] > SELECT `foos`.* FROM `foos` WHERE `foos`.`start` = '2000-01-01 12:30:00' LIMIT 1; Empty set (0.00 sec) root@localhost [test] > SELECT `foos`.* FROM `foos` WHERE `foos`.`start` = '12:30:00' LIMIT 1; +----+----------+---------------+ | id | start | finish | +----+----------+---------------+ | 1 | 12:30:00 | 12:30:00.9999 | +----+----------+---------------+ 1 row in set (0.00 sec) ```
* | Move `@quoted_{column|table}_names` cache up to the abstract adapterRyuta Kamizono2016-03-311-1/+1
| |
* | Fix description for method ↵Bogdan2016-03-271-2/+2
|/ | | | ActiveRecord::ConnectionAdapters::SchemaStatements#add_timestamps [ci skip]
* Merge pull request #24054 from kamipo/extract_default_primary_keyRafael França2016-03-111-1/+5
|\ | | | | Extract `default_primary_key?` to refactor `column_spec_for_primary_key`
| * Extract `default_primary_key?` to refactor `column_spec_for_primary_key`Ryuta Kamizono2016-03-111-1/+5
| |
* | Dump `bigint` instead of `integer` with `limit: 8` for schema dumperRyuta Kamizono2016-03-111-2/+6
|/ | | | | | | | | | | | | | | | | | Before: ```ruby create_table "big_numbers", force: :cascade do |t| t.integer "bigint_column", limit: 8 end ``` After: ```ruby create_table "big_numbers", force: :cascade do |t| t.bigint "bigint_column" end ```
* Fixed comments of add_foreign_key methodSalman Afzal Siddiqui2016-03-101-2/+2
| | | The comments of add_foreign_key method was displaying incorrect constraint name.
* Deprecate `{insert|update|delete}_sql` in `DatabaseStatements`Ryuta Kamizono2016-03-021-0/+3
| | | | | Originally, `{insert|update|delete}_sql` is protected methods. We can use the `{insert|update|delete}` public methods instead.