aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract
Commit message (Collapse)AuthorAgeFilesLines
* `:to_table` when adding a fk through `add_reference`.Yves Senn2015-10-132-3/+13
| | | | | | | | | | | | Closes #21563. The `name` argument of `add_references` was both used to generate the column name `<name>_id` and as the target table for the foreign key `name.pluralize`. It's primary purpose is to define the column name. In cases where the `to_table` of the foreign key is different than the column name we should be able to specify it individually.
* Move the methods for schema dumping into `{mysql,postgresql}/schema_dumper.rb`Ryuta Kamizono2015-10-131-1/+1
| | | | | Current master branch includes many schema dumping improvements. It extract these features to the appropriate files.
* Merge pull request #21005 from jaredbeck/patch-1Arthur Nogueira Neves2015-10-041-1/+3
|\ | | | | Docs: Update options for add_reference
| * Docs: Update options for add_referenceJared Beck2015-07-231-1/+3
| | | | | | [ci skip]
* | Fix minor docs [ci skip] amitkumarsuroliya2015-09-281-1/+1
| |
* | Fix proper fonts in `change_column_null` method docs. [ci skip]amitkumarsuroliya2015-09-271-2/+2
| |
* | introduce `conn.data_source_exists?` and `conn.data_sources`.Yves Senn2015-09-221-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These new methods are used from the Active Record model layer to determine which relations are viable to back a model. These new methods allow us to change `conn.tables` in the future to only return tables and no views. Same for `conn.table_exists?`. The goal is to provide the following introspection methods on the connection: * `tables` * `table_exists?` * `views` * `view_exists?` * `data_sources` (views + tables) * `data_source_exists?` (views + tables)
* | Merge pull request #21693 from joshuapinter/patch-1Jeremy Daer2015-09-201-0/+2
|\ \ | | | | | | Add title for key lengths for multiple keys.
| * | Add title for key lengths for multiple keys.Joshua Pinter2015-09-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Previously there was no separator between the two code examples so it looked like: ```ruby CREATE INDEX by_name ON accounts(name(10)) add_index(:accounts, [:name, :surname], name: 'by_name_surname', length: {name: 10, surname: 15}) ```
* | | Support for foreign keys in create tableRyuta Kamizono2015-09-202-17/+25
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If foreign keys specified in create table, generated SQL is slightly more efficient. Definition: ``` create_table :testings do |t| t.references :testing_parent, foreign_key: true end ``` Before: ``` CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer); ALTER TABLE "testings" ADD CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id"); ``` After: ``` CREATE TABLE "testings" ("id" serial primary key, "testing_parent_id" integer, CONSTRAINT "fk_rails_a196c353b2" FOREIGN KEY ("testing_parent_id") REFERENCES "testing_parents" ("id")); ```
* | Merge pull request #21589 from ↵Jeremy Daer2015-09-191-2/+6
|\ \ | | | | | | | | | | | | | | | kamipo/eliminate_duplicated_visit_table_definition Eliminate the duplication code of `visit_TableDefinition`
| * | Eliminate the duplication code of `visit_TableDefinition`Ryuta Kamizono2015-09-161-5/+13
| | |
* | | Merge pull request #21609 from kamipo/do_not_dump_view_as_tableJeremy Daer2015-09-191-0/+13
|\ \ \ | | | | | | | | | | | | Do not dump a view as a table in sqlite3, mysql and mysql2 adapters
| * | | Add `#views` and `#view_exists?` methods on connection adaptersRyuta Kamizono2015-09-131-0/+13
| | | |
* | | | Merge pull request #21607 from kamipo/remove_unnecessary_display_widthJeremy Daer2015-09-191-3/+3
|\ \ \ \ | | | | | | | | | | Remove unnecessary display width
| * | | | Remove unnecessary display widthRyuta Kamizono2015-09-161-3/+3
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | The **(11)** does not affect the storage size of the data type, which for an INT will always be 4 bytes. It affects the **display width**. http://www.tocker.ca/2015/07/02/proposal-to-deprecate-mysql-integer-display-width-and-zerofill.html
* | | | Merge pull request #21608 from ↵Jeremy Daer2015-09-192-10/+8
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | kamipo/eliminate_duplicated_options_include_default_method Eliminate the duplicated `options_include_default?` method
| * | | | Eliminate the duplicated `options_include_default?` methodRyuta Kamizono2015-09-132-10/+8
| | |/ / | |/| | | | | | | | | | Follow up 7ba2cd06.
* | | | Merge pull request #21614 from kamipo/correctly_dump_composite_primary_keyJeremy Daer (Kemper)2015-09-193-4/+30
|\ \ \ \ | | | | | | | | | | Correctly dump composite primary key
| * | | | Correctly dump composite primary keyRyuta Kamizono2015-09-203-4/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: create_table :barcodes, primary_key: ["region", "code"] do |t| t.string :region t.integer :code end
* | | | | Replaced `ThreadSafe::Map` with successor `Concurrent::Map`.Jerry D'Antonio2015-09-191-6/+6
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | The thread_safe gem is being deprecated and all its code has been merged into the concurrent-ruby gem. The new class, Concurrent::Map, is exactly the same as its predecessor except for fixes to two bugs discovered during the merge.
* | | | Merge pull request #21637 from amitsuroliya/doc_fixesKasper Timm Hansen2015-09-171-2/+2
|\ \ \ \ | | | | | | | | | | Improved ActiveRecord Connection Pool docs [ci skip]
| * | | | Improved ActiveRecord Connection Pool docs [ci skip]amitkumarsuroliya2015-09-171-2/+2
| | |/ / | |/| |
* / | | s/Github/GitHub/Akira Matsuda2015-09-171-1/+1
|/ / / | | | | | | | | | [ci skip]
* | | [ci skip] Remove `DEFAULT NULL` from examplesYasuo Honda2015-09-161-2/+2
| | |
* | | Fix doc of limit option for a text column [ci skip]Ryuta Kamizono2015-09-141-2/+2
|/ / | | | | | | | | | | | | | | | | Follow up #21591. The document of limit option for a text column is incorrect. MySQL: the limit is byte length, not character length Pg, Sqlite3: variable unlimited length
* | Updated MySQL documentation link to MySQL latest version 5.7 everywhere [ci ↵amitkumarsuroliya2015-09-101-2/+2
| | | | | | | | | | skip] Bumps from `5.6` to `5.7`
* | Don't set the default argumentRafael Mendonça França2015-09-091-1/+1
| | | | | | | | It is always passed in
* | Merge pull request #21548 from yui-knk/feature/define_tables_as_interfaceYves Senn2015-09-081-0/+5
|\ \ | | | | | | | | | Define `SchemaStatements#tables` as interface
| * | Define `SchemaStatements#tables` as interfaceyui-knk2015-09-081-0/+6
|/ / | | | | | | | | | | | | | | | | These 3 methods expect `ConnectionAdapters` to have `tables` method, so make it clear that `tables` method is interface. * `ConnectionAdapters::SchemaCache#prepare_tables` * `db:schema:cache:dump` task * `SchemaDumper#tables`
* | Support dropping indexes concurrently in PostgresGrey Baker2015-09-051-4/+1
| | | | | | | | | | See http://www.postgresql.org/docs/9.4/static/sql-dropindex.html for more details.
* | Merge pull request #21282 from sjain1107/added_docsYves Senn2015-08-191-0/+3
|\ \ | | | | | | | | | Added docs for TableDefinition #coloumns & #remove_column [ci skip]
| * | Added docs for TableDefinition #coloumns & #remove_column [ci skip]sjain11072015-08-181-0/+3
|/ /
* / descriptive error message when fixtures contian a missing column.Yves Senn2015-08-131-2/+6
|/ | | | Closes #21201.
* Fixes documentation typo.Дмитро Будник2015-07-231-2/+2
| | | Documentation had extra colon after keyword.
* Revert "Revert "Reduce allocations when running AR callbacks.""Guo Xiang Tan2015-07-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit bdc1d329d4eea823d07cf010064bd19c07099ff3. Before: Calculating ------------------------------------- 22.000 i/100ms ------------------------------------------------- 229.700 (± 0.4%) i/s - 1.166k Total Allocated Object: 9939 After: Calculating ------------------------------------- 24.000 i/100ms ------------------------------------------------- 246.443 (± 0.8%) i/s - 1.248k Total Allocated Object: 7939 ``` begin require 'bundler/inline' rescue LoadError => e $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' raise e end gemfile(true) do source 'https://rubygems.org' # gem 'rails', github: 'rails/rails', ref: 'bdc1d329d4eea823d07cf010064bd19c07099ff3' gem 'rails', github: 'rails/rails', ref: 'd2876141d08341ec67cf6a11a073d1acfb920de7' gem 'arel', github: 'rails/arel' gem 'sqlite3' gem 'benchmark-ips' end require 'active_record' require 'benchmark/ips' ActiveRecord::Base.establish_connection('sqlite3::memory:') ActiveRecord::Migration.verbose = false ActiveRecord::Schema.define do create_table :users, force: true do |t| t.string :name, :email t.boolean :admin t.timestamps null: false end end class User < ActiveRecord::Base default_scope { where(admin: true) } end admin = true 1000.times do attributes = { name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", email: "foobar@email.com", admin: admin } User.create!(attributes) admin = !admin end GC.disable Benchmark.ips(5, 3) do |x| x.report { User.all.to_a } end key = if RUBY_VERSION < '2.2' :total_allocated_object else :total_allocated_objects end before = GC.stat[key] User.all.to_a after = GC.stat[key] puts "Total Allocated Object: #{after - before}" ```
* Merge pull request #20699 from ↵Rafael Mendonça França2015-06-271-1/+4
|\ | | | | | | | | vngrs/foreign_key_with_table_name_suffix_and_prefix Add table name prefix and suffix support for foreign keys
| * Add table name prefix and suffix support to add_foreign_key and ↵Mehmet Emin İNAÇ2015-06-251-1/+4
| | | | | | | | | | | | remove_foreign_key methods fix tests
* | Add reversible syntax for change_column_defaultPrem Sichanugrist2015-06-262-3/+17
|/ | | | | | | | | | | | | Passing `:from` and `:to` to `change_column_default` makes this command reversible as user has defined its previous state. So, instead of having the migration command as: change_column_default(:posts, :state, "draft") They can write it as: change_column_default(:posts, :state, from: nil, to: "draft")
* make `remove_index :table, :column` reversible.Yves Senn2015-06-151-1/+1
| | | | | | | | | This used to raise a `IrreversibleMigration` error (since #10437). However since `remove_index :table, :column` is probably the most basic use-case we should make it reversible again. Conflicts: activerecord/CHANGELOG.md
* Merge pull request #20226 from EpicH0liday/reversible-remove-foreign-keyYves Senn2015-06-121-1/+5
|\ | | | | | | | | | | | | Make remove_foreign_key reversible Conflicts: activerecord/CHANGELOG.md
| * Add an invert method for remove_foreign_keyAster Ryan2015-06-111-1/+6
|/
* A few documentation tweaks [ci skip]Robin Dupret2015-06-071-1/+1
| | | | [Robin Dupret & Shunsuke Aida]
* Updated postgresql documentation link to use latest version [ci skip]Ronak Jangir2015-05-201-1/+1
|
* Remove unused already requireRyuta Kamizono2015-05-191-4/+0
|
* Merge pull request #20175 from eugeneius/copy_schema_cache_after_forkRafael Mendonça França2015-05-181-1/+3
|\ | | | | Add schema cache to new connection pool after fork
| * Add schema cache to new connection pool after forkEugene Kenny2015-05-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Active Record detects when the process has forked and automatically creates a new connection pool to avoid sharing file descriptors. If the existing connection pool had a schema cache associated with it, the new pool should copy it to avoid unnecessarily querying the database for its schema. The code to detect that the process has forked is in ConnectionHandler, but the existing test for it was in the ConnectionManagement test file. I moved it to the right place while I was writing the new test for this change.
* | Merge pull request #20192 from kamipo/divide_to_column_options_handling_methodsRafael Mendonça França2015-05-181-4/+24
|\ \ | | | | | | Divide methods for handling column options separately
| * | Divide methods for handling column options separatelyRyuta Kamizono2015-05-181-4/+24
| |/
* / better `add_reference` documentation. [ci skip]Yves Senn2015-05-182-20/+18
|/ | | | | | | | | This patch - reduces the duplication among the `reference`-family methods. - better explains all the optians available for `add_reference`. - redirects to user from `references` to `add_reference`. Originated by #20184.