aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
Commit message (Collapse)AuthorAgeFilesLines
* `add_reference` should respect column position for both reference id and ↵Ryuta Kamizono2017-09-011-1/+1
| | | | | | type columns Fixes #30496.
* Clarify intentions around method redefinitionsMatthew Draper2017-09-011-3/+2
| | | | | | | | | Don't use remove_method or remove_possible_method just before a new definition: at best the purpose is unclear, and at worst it creates a race condition. Instead, prefer redefine_method when practical, and silence_redefinition_of_method otherwise.
* Merge pull request #30377 from keepcosmos/delegate-missing-methodsMatthew Draper2017-08-311-2/+2
|\ | | | | Delegate :rindex, :slice, :rotate(missing) to 'records'
| * Delegate :rindex, :slice, :rotate to 'records'keepcosmos2017-08-241-2/+2
| |
* | Fix `can't modify frozen String` error in `DatabaseTasks`yuuji.yaginuma2017-08-302-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this, `db:structure:dump` task raises an error as follwing: ``` can't modify frozen String activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:77:in `run_cmd_error' activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:72:in `run_cmd' activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:52:in `structure_dump' activerecord/lib/active_record/tasks/database_tasks.rb:219:in `structure_dump' activerecord/lib/active_record/railties/databases.rake:279:in `block (3 levels) in <main>' railties/lib/rails/commands/rake/rake_command.rb:23:in `block in perform' railties/lib/rails/commands/rake/rake_command.rb:20:in `perform' railties/lib/rails/command.rb:48:in `invoke' railties/lib/rails/commands.rb:18:in `<main>' ```
* | Merge pull request #30445 from prathamesh-sonpatki/fix-30441Kasper Timm Hansen2017-08-281-0/+2
|\ \ | | | | | | Clarify that bulk option is supported only by MySQL
| * | Clarify that bulk option is supported only by MySQL [ci skip]Prathamesh Sonpatki2017-08-291-0/+2
| | | | | | | | | | | | - Closes #30441
* | | `@previous_reflection.options[:source_type]` in `PolymorphicReflection` is ↵Ryuta Kamizono2017-08-281-10/+2
| | | | | | | | | | | | | | | | | | | | | always true Because `add_as_polymorphic_through` is only called when `options[:source_type]` is true.
* | | Remove unused `RuntimeReflection#alias_candidate`Ryuta Kamizono2017-08-281-4/+0
| | | | | | | | | | | | `RuntimeReflection#alias_candidate` is no longer used since 0408e212.
* | | Should be appear deprecation message for every call (#29649)Ryuta Kamizono2017-08-271-8/+0
| | | | | | | | | Context: https://github.com/rails/rails/pull/29619#discussion_r125158589
* | | Omit the default limit for float columns (#28041)Ryuta Kamizono2017-08-271-1/+1
| | |
* | | Prefer to place a table options before `force: :cascade` (#28005)Ryuta Kamizono2017-08-271-2/+1
|/ / | | | | | | | | | | I was added a table options after `force: :cascade` in #17569 for not touching existing tests (reducing diff). But `force: :cascade` is not an important information. So I prefer to place a table options before `force: :cascade`.
* | Use tt in doc for ActiveRecord [ci skip]Yoshiyuki Hirano2017-08-276-20/+20
| |
* | Merge pull request #30403 from yhirano55/fix_broken_doc_for_active_recordRyuta Kamizono2017-08-267-7/+7
|\ \ | | | | | | Fix broken doc for Active Record [ci skip]
| * | Fix broken doc for Active Record [ci skip]Yoshiyuki Hirano2017-08-257-7/+7
| | |
* | | Add :nodoc: for ActiveRecord::AttributeMethods [ci skip]Yoshiyuki Hirano2017-08-263-3/+3
| | |
* | | Should work inverse association when eager loadingRyuta Kamizono2017-08-253-15/+18
|/ / | | | | | | | | | | | | This regression was caused by caa178c1. The block for `set_inverse_instance` should also be passed to join dependency. Fixes #30402.
* | Remove unused returning value `stream`Ryuta Kamizono2017-08-241-2/+0
| |
* | Merge pull request #30337 from kamipo/refactor_schema_dumperRyuta Kamizono2017-08-2413-52/+50
|\ \ | |/ |/| Refactor `SchemaDumper` to make it possible to adapter specific customization
| * Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-2213-38/+51
| | | | | | | | | | | | | | Currently `SchemaDumper` is only customizable for column options. But 3rd party connection adapters (oracle-enhanced etc) need to customizable for table or index dumping also. To make it possible, I introduced adapter specific `SchemaDumper` classes for that.
| * Remove deprecated `#migration_keys`Ryuta Kamizono2017-08-223-15/+0
| |
* | Merge pull request #30360 from gcourtemanche/transaction_timedoutRafael França2017-08-222-0/+8
|\ \ | |/ |/| Add TransactionTimeout for MySQL error code 1205
| * Add TransactionTimeout for MySQL error code 1205Gabriel Courtemanche2017-08-222-0/+8
| |
* | Automatically guess the inverse associations for STIyui-knk2017-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord associations automatically guess the inverse associations. But this feature does not work correctly on assoctions for STI. For example, before this commit ``` class Post < ActiveRecord::Base belongs_to :author end class SpecialPost < Post; end class Author < ActiveRecord::Base has_many :posts has_many :special_posts end ``` `author.posts.first.author` works correctly, but `author.special_posts.first.author` does not work correctly.
* | Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-2211-12/+12
|/
* Prevent extra `SET time zone` in `configure_connection` (#28413)Ryuta Kamizono2017-08-211-6/+8
| | | | | | | | `SET time zone 'value'` is an alias for `SET timezone TO 'value'`. https://www.postgresql.org/docs/current/static/sql-set.html So if `variables["timezone"]` is specified, it is enough to `SET timezone` once.
* Require "active_support/core_ext/hash/compact" for `compact!`Ryuta Kamizono2017-08-211-0/+2
|
* Prefer formatted number as schema version [ci skip]Ryuta Kamizono2017-08-211-1/+1
|
* Place `update_table_definition` consistently in `SchemaStatements`Ryuta Kamizono2017-08-216-12/+12
|
* Don't expose `prepare_column_options`Ryuta Kamizono2017-08-213-52/+30
| | | | | This is only used for the internal `column_spec` and `column_spec_for_primary_key`.
* Register integer types limit correctly for postgresql adapter (#26386)Ryuta Kamizono2017-08-201-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | currently integer types extracts the `limit` from `sql_type`. But the lookup key of type map is the `oid` in postgresql adapter. So in most case `sql_type` is passed to `extract_limit` as `""` and `limit` is extracted as `nil`. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L445 In mysql2 adapter, `limit` is registered correctly without extracting from `sql_type`. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L678-L682 Postgresql adapter should also be registered correctly. ``` ruby conn = ActiveRecord::Base.connection conn.select_all("SELECT 1::smallint, 2::integer, 3::bigint").column_types.map do |name, type| [name, type.limit] end ``` Before: ``` ruby # => [["int2", nil], ["int4", nil], ["int8", nil]] ``` After: ``` ruby # => [["int2", 2], ["int4", 4], ["int8", 8]] ```
* Restore the ability that SQL with binds for `insert`, `update`, and `delete` ↵Ryuta Kamizono2017-08-181-6/+6
| | | | | | | | (#29944) Since 213796f, it was lost the ability that SQL with binds for `insert`, `update`, and `delete` (like `select_all`). This restores the ability because `insert`, `update`, and `delete` are public API, so it should not be removed without deprecation.
* Restore `to_sql` to return only SQL (#29945)Ryuta Kamizono2017-08-186-13/+15
| | | | Because `to_sql` is public API. I introduced `to_sql_and_binds` internal API to return SQL and binds.
* Merge pull request #30048 from yahonda/regexp_aware_schema_dumper_prefix_suffixRafael França2017-08-161-1/+3
|\ | | | | Allow `table_name_prefix` and `table_name_suffix` have `$`
| * Allow `table_name_prefix` and `table_name_suffix` have `$`Yasuo Honda2017-08-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL 5.7 and PostgreSQL 9.6 allow table identifiers have the dollar sign. * MySQL 5.7 https://dev.mysql.com/doc/refman/5.7/en/identifiers.html > Permitted characters in unquoted identifiers: > ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) * PostgreSQL 9.6 https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html > SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard. Address #30044 [Yasuo Honda & Ryuta Kamizono]
* | Add spaceJon Moss2017-08-161-1/+1
| | | | | | | | [ci skip]
* | Fix RuboCop offensesKoichi ITO2017-08-161-5/+6
| | | | | | | | And enable `context_dependent` of Style/BracesAroundHashParameters cop.
* | Merge pull request #30271 from ↵Rafael França2017-08-154-19/+14
|\ \ | | | | | | | | | | | | kamipo/through_scope_should_not_be_affected_by_scoping Through scope should not be affected by scoping
| * | Through scope should not be affected by scopingRyuta Kamizono2017-08-154-19/+14
| | | | | | | | | | | | | | | | | | Follow up of #29834. Fixes #30266.
* | | Don't expose `write_attribute_without_type_cast`Ryuta Kamizono2017-08-161-6/+5
|/ / | | | | | | | | | | `write_attribute_without_type_cast` is defined as a private method in `AttributeMethods::Write`, but `AttributeMethods::Dirty` overrode it as a public method. It should be kept the original visibility.
* | Merge pull request #30169 from awortham/awortham/awortham/fix-sql-distinct-bugRafael Mendonça França2017-08-141-0/+3
|\ \ | | | | | | | | | Ensure sum honors distinct on has_many through
| * | Ensure sum honors distinct on has_many throughAaron Wortham2017-08-141-0/+3
| | | | | | | | | | | | | | | | | | When using a has_many through relation and then summing an attribute the distinct was not being used. This will ensure that when summing an attribute, the number is only used once when distinct has been used.
* | | Merge pull request #30073 from yalab/fixture_binary_helperRafael França2017-08-141-0/+4
|\ \ \ | | | | | | | | Add `binary` helper method to fixtures.
| * | | Add `binary` helper method to fixtures.yalab2017-08-121-0/+4
| | | |
* | | | Merge pull request #30208 from kamipo/extract_primary_key_to_abstract_reflectionRafael França2017-08-141-8/+4
|\ \ \ \ | | | | | | | | | | Extract `primary_key` to `AbstractReflection`
| * | | | Extract `primary_key` to `AbstractReflection`Ryuta Kamizono2017-08-121-8/+4
| | | | |
* | | | | Merge pull request #27609 from kamipo/fix_association_primary_keyRafael França2017-08-142-4/+11
|\ \ \ \ \ | | | | | | | | | | | | Fix `reflection.association_primary_key` for `has_many` association
| * | | | | Fix `reflection.association_primary_key` for `has_many` associationsRyuta Kamizono2017-08-132-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is incorrect to treat `options[:primary_key]` as `association_primary_key` if `has_many` associations because the `:primary_key` means the column on the owner record, not on the association record. It will break `ids_reader` and `ids_writer`. ```ruby people(:david).essay_ids # => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David' ``` Fixes #14439.
* | | | | | Merge pull request #30229 from kamipo/allow_serialize_with_custom_coderRafael França2017-08-141-7/+4
|\ \ \ \ \ \ | | | | | | | | | | | | | | Allow `serialize` with a custom coder on `json` and `array` columns
| * | | | | | Allow `serialize` with a custom coder on `json` and `array` columnsRyuta Kamizono2017-08-131-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already have a test case for `serialize` with a custom coder in `PostgresqlHstoreTest`. https://github.com/rails/rails/blob/v5.1.3/activerecord/test/cases/adapters/postgresql/hstore_test.rb#L316-L335