aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
* Don't pass `table` to `last_chain_scope` and `next_chain_scope`Ryuta Kamizono2017-09-072-19/+17
| | | | | | Because `table` is part of `reflection`, don't need to pass it explicitly. And also, naming `alias_name` to `table` is a little confusing. `aliased_table` is preferable than `alias_name`.
* `RuntimeReflection` is not a subclass of `PolymorphicReflection`Ryuta Kamizono2017-09-071-26/+6
| | | | | | `PolymorphicReflection` is an internal class that is used in `ThroughReflection`. But `RuntimeReflection` is used for the head of chain in `AssociationScope`. These are totally different things.
* `has_many :through` with unscope should affect to through scopeRyuta Kamizono2017-09-074-23/+19
| | | | | | | | | The order of scope evaluation should be from through scope to the association's own scope. Otherwise the association's scope cannot affect to through scope. Fixes #13677. Closes #28449.
* Don't pass unneeded `reflection` to `add_constraints`Ryuta Kamizono2017-09-051-3/+3
| | | | Because `refl.scope` is the same meaning with `chain_head.scope`.
* Assigning `values` is only necessary when `reflection_scope.where_clause` is ↵Ryuta Kamizono2017-09-051-1/+1
| | | | | | not empty Because `reflection_scope.values` will create extra new hash.
* Don't merge `reflection_scope` if `reflection.scope` isn't givenRyuta Kamizono2017-09-051-1/+1
| | | | | If `reflection.scope` isn't given, `reflection_scope` is always `klass.unscoped`. it is unnecessary to merge it.
* Should quote composite primary key namesRyuta Kamizono2017-09-042-2/+12
| | | | | | | Otherwise using reserved words as composite primary key names will be failed as an invalid SQL. Fixes #30518.
* Scope in associations should treat nil as `all`Ryuta Kamizono2017-09-046-9/+11
| | | | | | | | Defined scope treats nil as `all`, but scope in associations isn't so. If the result of the scope is nil, most features on associations will be broken. It should treat nil as `all` like defined scope. Fixes #20823.
* Don't expose `find_all_ordered` utility method in testsRyuta Kamizono2017-09-021-4/+5
| | | | Because this is not a test case.
* Fix preloading through association with custom scopeRyuta Kamizono2017-09-022-1/+11
| | | | | | | | | | If `reflection_scope.where_clause` is not empty, `through_scope` should be joined the source association. But if `values[:references]` in `reflection_scope` is empty, the source association will not be joined. It should use `source_reflection.table_name` in that case. Fixes #22535. Closes #28763.
* Add a test case for preloading through association with implicit sourceRyuta Kamizono2017-09-021-0/+8
| | | | | | | | | | | | | | | | If `reflection_scope.where_clause` is not empty, `through_scope` should be joined the source association. But if the through association doesn't have explicit `:source`, `options[:source]` will be nil and `scope.includes_values` will also be empty. It should use `source_reflection.name` rather than `options[:source]`. Fixed by a26cff3c1235c61cd0135bed4ef63d7be452b458. Fixes #11078. Fixes #26129. Closes #14312. Closes #29155. Closes #29841.
* `values[:includes]` in `reflection_scope` is not compatible with `through_scope`Ryuta Kamizono2017-09-022-2/+7
| | | | | | | | | | | | | | | | | Without this fix, preloading `:comments_with_include` will cause the following error: ``` % bundle exec ruby -w -Itest test/cases/associations/eager_test.rb -n test_eager_with_has_many_through_join_model_with_include Using sqlite3 Run options: -n test_eager_with_has_many_through_join_model_with_include --seed 1502 E Error: EagerAssociationTest#test_eager_with_has_many_through_join_model_with_include: ActiveRecord::AssociationNotFoundError: Association named 'post' was not found on Post; perhaps you misspelled it? ```
* Don't call `scope.eager_loading?` when `reflection_scope.where_clause` is emptyRyuta Kamizono2017-09-021-10/+10
| | | | | If `reflection_scope.where_clause` is empty, `scope` isn't changed. So `scope.eager_loading?` is always false.
* sqlite3 adapter returns integer value which used to be stringYasuo Honda2017-09-012-9/+4
| | | | | | | | | | | | | | | | | | | | | | | `to_i` was added for SQLite3 adapter which did not handle number but sqlite3 gem already supports it then `to_i` is unnecessary. else condition is kept for adapters which return string, i.e. mysql(not mysql2) and sqlserver. Renamed `test_cache_does_not_wrap_string_results_in_arrays` to `test_cache_does_not_wrap_results_in_arrays` to explain the current behavior. most of adapters return integer, not only string. * Refer these commits: "future proofing the sqlite3 adapter code" https://github.com/rails/rails/commit/beda2d43d6ac5c3435fc2fba0cbd108c20fe1c67 "Refactor calculation test to remove unneeded SQLite special case." https://github.com/rails/rails/commit/47d568ed3fc701934ebe80b276f3d8bf6951c93f "no need to to_i, sqlite does that for us" https://github.com/rails/rails/commit/6cf44a1bd64ba10497742d70ad78fe68faa16e99
* Merge pull request #29850 from yahonda/test_with_mariadb_102_on_trustyRyuta Kamizono2017-09-011-0/+4
|\ | | | | CI with the latest stable(GA) version of MariaDB 10.2
| * Skip `test_remove_column_with_multi_column_index`Yasuo Honda2017-09-011-0/+4
| | | | | | | | | | | | | | | | | | | | when tested with MariaDB 10.2.8 or higher Refer #30485 https://mariadb.com/kb/en/the-mariadb-library/alter-table/#drop-column-if-exists-col_name-cascaderestrict > MariaDB starting with 10.2.8 > Dropping a column that is part of a multi-column UNIQUE constraint is not permitted.
* | `add_reference` should respect column position for both reference id and ↵Ryuta Kamizono2017-09-012-1/+11
|/ | | | | | type columns Fixes #30496.
* :warning: assigned but unused variable - messageAkira Matsuda2017-09-011-6/+6
|
* 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-312-4/+4
|\ | | | | Delegate :rindex, :slice, :rotate(missing) to 'records'
| * Delegate :rindex, :slice, :rotate to 'records'keepcosmos2017-08-242-4/+4
| |
* | Merge pull request #30392 from koic/unify_source_control_keep_file_nameMatthew Draper2017-08-311-0/+0
|\ \ | | | | | | Unify the internal source control .keep file name
| * | Unify the internal source control .keep file nameKoichi ITO2017-08-241-0/+0
| |/
* | Fix `can't modify frozen String` error in `DatabaseTasks`yuuji.yaginuma2017-08-304-2/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #30439 from prathamesh-sonpatki/changelog-30360Ryuta Kamizono2017-08-291-0/+5
|\ \ | | | | | | Added CHANGELOG for #30360 [ci skip]
| * | Added CHANGELOG for #30360 [ci skip]Prathamesh Sonpatki2017-08-281-0/+5
| | |
* | | 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
* | | "models/reader" is no longer used in `autosave_association_test.rb`Ryuta Kamizono2017-08-281-1/+0
| | |
* | | Address `test_assign_ids_for_through_a_belongs_to` failureRyuta Kamizono2017-08-281-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | If `:readers` fixture is loaded before the test, it will be failed. Use `firm.developer_ids` instead because we don't have `:contracts` fixture for now. https://travis-ci.org/rails/rails/jobs/268976230#L729
* | | `@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-272-8/+1
| | | | | | | | | Context: https://github.com/rails/rails/pull/29619#discussion_r125158589
* | | Omit the default limit for float columns (#28041)Ryuta Kamizono2017-08-273-5/+10
| | |
* | | Prefer to place a table options before `force: :cascade` (#28005)Ryuta Kamizono2017-08-275-11/+10
|/ / | | | | | | | | | | 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
| |
* | Fix random CI failure due to non-deterministic sorting orderRyuta Kamizono2017-08-261-6/+6
| | | | | | | | https://travis-ci.org/rails/rails/jobs/268599781#L784
* | 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-254-15/+24
|/ / | | | | | | | | | | | | This regression was caused by caa178c1. The block for `set_inverse_instance` should also be passed to join dependency. Fixes #30402.
* | Address `test_after_save_callback_with_autosave` failureYasuo Honda2017-08-241-0/+4
| | | | | | | | | | | | | | when other `AutomaticInverseFindingTests` load `:comments` fixture but does not load `:posts`. Refer #30385 for similar issue
* | Remove unused returning value `stream`Ryuta Kamizono2017-08-241-2/+0
| |
* | Merge pull request #30337 from kamipo/refactor_schema_dumperRyuta Kamizono2017-08-2415-56/+54
|\ \ | | | | | | 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-225-19/+4
| | |
* | | Remove unnecessary fixture loadingRyuta Kamizono2017-08-241-5/+1
| |/ |/|
* | Merge pull request #30365 from yahonda/require_post_before_commentRyuta Kamizono2017-08-231-0/+3
|\ \ | | | | | | `counter_cache` requires association class before `attr_readonly`
| * | `counter_cache` requires association class before `attr_readonly`Yasuo Honda2017-08-231-0/+3
| |/ | | | | | | | | There were similar pull requests #26370 #27575 fixed by different way by moving `require "models/post"` before `require "models/comment"`
* | Merge pull request #28991 from yahonda/load_authors_and_author_addressesRyuta Kamizono2017-08-234-4/+4
|\ \ | | | | | | Load :author_addresses fixture to keep data integrity with :authors