aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
Commit message (Collapse)AuthorAgeFilesLines
* Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-1/+2
| | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-075-6/+0
|
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-062-129/+129
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-062-7/+5
|
* modernizes hash syntax in activerecordXavier Noria2016-08-0617-671/+671
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-0620-961/+961
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Merge pull request #25767 from ↵Rafael França2016-07-271-0/+6
|\ | | | | | | | | kamipo/association_name_is_the_same_as_join_table_name Correctly return `associated_table` when `associated_with?` is true
| * Correctly return `associated_table` when `associated_with?` is trueRyuta Kamizono2016-07-101-0/+6
| | | | | | | | | | | | | | `AssociationQueryHandler` requires `association` initialized `TableMetadata` even if `table_name == arel_table.name`. Fixes #25689.
* | Add an assertion to the tests that should be loaded the target.Ryuta Kamizono2016-07-271-0/+38
| | | | | | | | These test cases tests exactly mutating loaded target.
* | Make `force_signal37_to_load_all_clients_of_firm` to privateRyuta Kamizono2016-07-261-4/+6
| | | | | | | | This is not a test case.
* | adds missing requiresXavier Noria2016-07-241-0/+1
| |
* | systematic revision of =~ usage in ARXavier Noria2016-07-232-6/+6
| | | | | | | | | | Where appropriatei, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
* | Add `exists?` and `update_all` to `CollectionProxy` for respects an ↵Ryuta Kamizono2016-07-201-0/+20
| | | | | | | | | | | | association scope Fixes #25732.
* | Merge pull request #25578 from ↵Rafael França2016-07-201-1/+1
|\ \ | | | | | | | | | | | | kamipo/move_warning_about_composite_primary_key_to_attribute_methods_primary_key Move the warning about composite primary key to `AttributeMethods::PrimaryKey`
| * | Move the warning about composite primary key to `AttributeMethods::PrimaryKey`Ryuta Kamizono2016-07-021-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | Actually schema dumper/creation supports composite primary key (#21614). Therefore it should not show the warning about composite primary key in connection adapter. This change moves the warning to `AttributeMethods::PrimaryKey` and suppress the warning for habtm join table. Fixes #25388.
* / Refactored test ↵bogdanvlviv2016-07-171-1/+2
|/ | | | `HasManyAssociationsTest#test_do_not_call_callbacks_for_delete_all`
* Fix `calculate` with a string value in `from` and eager loadingRyuta Kamizono2016-06-131-0/+4
| | | | | | | | | | `construct_relation_for_association_calculations` pass a string value to `construct_join_dependency` when setting a string value in `from`. It should not pass a string value, but always `joins_values`. Related #14834, #19452. Fixes #24193.
* Allow Oracle bind parameter syntax `:a1`Yasuo Honda2016-06-081-1/+1
|
* Exists shouldn't error when used with `includes`Sean Griffin2016-05-301-0/+1
| | | | | | | | | | | | | | | | Currently `exists?` does some hackery where it assumes that we can join onto anything that we passed to `eager_load` or `includes`, which doesn't work if we are joining onto a polymorphic association. Actually figuring out if we want to include something would require knowledge deep within the join dependency module, which is hard to pull up. The simplest solution is just to pass a flag down that says we're not actually going to try to eager load any of the data. It's not the solution I'd like, but that code really needs to be untangled before we can do much with it. This is another attempt at 6d5b1fd which should address the concerns that led to reverting it in 4ecabed.
* Fix `has_one` `enum` `where` queriesJon Moss2016-05-261-0/+18
| | | | Fixes #25128
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-182-3/+3
| | | | | | | | 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.
* Give more context from `AssociationMismatchError`Sean Griffin2016-05-121-1/+1
| | | | | | | The error message that we give today makes this error difficult to debug if you receive it. I have no clue why we're printing the object ID of the class (the commit doesn't give context), but I've left it as it was deliberate.
* Rename test methodMolchanov Andrey2016-05-121-1/+1
|
* Fix counter_cache double increment bugTom Kadwill2016-04-281-0/+11
|
* Fix undefined method `owners' for NullPreloader:ClassLadislav Smola2016-04-061-0/+14
| | | | | | | | | | | | | | * Fix undefined method `owners' for NullPreloader:Class Fixing undefined method `owners' for ActiveRecord::Associations::Preloader::NullPreloader:Class * Use Ruby 1.9 hash format Use Ruby 1.9 hash format #24192 [Rafael Mendonça França + Ladislav Smola]
* Merge pull request #22518 from ↵Arthur Nogueira Neves2016-03-181-0/+17
|\ | | | | | | | | RochesterinNYC/better-error-message-for-includes-relations-missing Improve error message for missing relations for includes and eager_load
| * Improve clarity of error message for missing includes and eager_loadJames Wen2016-01-281-0/+17
| | | | | | | | relations
* | don't treat all associations with extensions as instance dependent.Yves Senn2016-03-031-0/+12
| | | | | | | | | | | | | | | | | | | | Closes #23934. This is a forward port of ac832a43b4d026dbad28fed196d2de69ec9928ac Previously the scope of all associations with extensions were wrapped in an instance dependent proc. This made it impossible to preload such associations.
* | Remove duplicated `test_` prefix [ci skip]Ryuta Kamizono2016-03-021-1/+1
| |
* | Respect through association scopes when used with polymorphicSean Griffin2016-02-291-0/+7
| | | | | | | | | | | | | | | | | | | | | | When the `source_type` option is passed to a has_many through, the resulting `Reflection` will be an instance of `PolymorphicReflection` and not `ThroughReflection`, meaning that it will ignore the scopes that it needs to apply from the through reflections. This adds an additional delegation call to remedy this. I've been finding the reflection code completely impenetrable lately, it could use some major love. Fixes #22726
* | Merge pull request #18766 from yasyf/issue_17864Sean Griffin2016-02-291-0/+32
|\ \ | | | | | | | | | | | | Honour joining model order in `has_many :through` associations when eager loading
| * | Honour the order of the joining model in a `has_many :through`Yasyf Mohamedali2015-03-021-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | association when eager loading. Previously, eager loading a `has_many :through` association with no defined order would return the records in the natural order of the database. Now, these records will be returned in the order that the joining record is returned, in case there is a defined order there.
* | | remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-224-10/+10
| | |
* | | fix typoLobsiinvok2016-02-201-1/+1
| | |
* | | eliminate warnings about multiple primary keys on habtm join tablesAaron Patterson2016-02-191-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | habtm join tables commonly have two id columns and it's OK to make those two id columns a primary key. This commit eliminates the warnings for join tables that have this setup. ManageIQ/manageiq#6713
* | | rename to 'second_to_last' and 'third_to_last'Brian Christian2016-02-101-4/+4
| | |
* | | allow Array.penultimate and Array.antepenultiate access methodsBrian Christian2016-02-091-0/+10
| | |
* | | Typos in AR testsAkira Matsuda2016-02-041-1/+1
| | |
* | | Typos in AR testsAkira Matsuda2016-02-032-6/+6
| | |
* | | Merge pull request #20997 from himesh-r/issue-20995Arthur Neves2016-02-021-1/+1
|\ \ \ | |_|/ |/| | | | | | | | Changed id-writer to save join table records based on association primary key #20995.
| * | Changed id-writer to save join table records based on association primary ↵Himesh2016-02-021-1/+1
| | | | | | | | | | | | | | | | | | key #20995 Changed id-writer to save join table records based on association primary key
* | | Revert "Merge pull request #22486 from ↵Yves Senn2015-12-211-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | methyl/fix-includes-for-groupped-association" This reverts commit 537ac7d6ade61e95f2b70685ff2236b7de965bab, reversing changes made to 9c9c54abe08d86967efd3dcac1d65158a0ff74ea. Reason: The way we preload associations will change the meaning of GROUP BY operations. This is illustrated in the SQL generated by the added test (failing on PG): Association Load: D, [2015-12-21T12:26:07.169920 #26969] DEBUG -- : Post Load (0.7ms) SELECT "posts".* FROM "posts" LEFT JOIN comments ON comments.post_id = posts.id WHERE "posts"."author_id" = $1 GROUP BY posts.id ORDER BY SUM(comments.tags_count) [["author_id", 1]] Preload: D, [2015-12-21T12:26:07.128305 #26969] DEBUG -- : Post Load (1.3ms) SELECT "posts".* FROM "posts" LEFT JOIN comments ON comments.post_id = posts.id WHERE "posts"."author_id" IN (1, 2, 3) GROUP BY posts.id ORDER BY SUM(comments.tags_count)
* | | Merge pull request #22486 from methyl/fix-includes-for-groupped-associationYves Senn2015-12-211-0/+17
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Pass group values when including association Conflicts: activerecord/CHANGELOG.md
| * | | Pass SQL group by values when including scoped associationLucjan Suski2015-12-151-0/+13
| | | | | | | | | | | | | | | | | | | | Fixes problem when added `group()` in association scope was lost in eager loaded association.
* | | | Merge pull request #19423 from ↵Aaron Patterson2015-12-181-0/+6
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | yuroyoro/fix_performance_regression_of_preloading_has_many_through_relation Fix #12537 performance regression when preloading has_many_through association
| * | | | Read already loaded association records from association.targetTomohito Ozaki2015-04-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | For performance, Avoid instantiate CollectionProxy. Fixes #12537
* | | | | Remove legacy mysql adapterAbdelkader Boudih2015-12-171-1/+1
| |/ / / |/| | |
* | | | Bugfix collection association #create method …Bogdan Gusiev2015-11-231-0/+6
| | | | | | | | | | | | | | | | | | | | When same association is loaded in the model creation callback The new object is inserted into association twice
* | | | Except keys of `build_record`'s argument from `create_scope` in ↵yui-knk2015-11-161-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initialize_attributes If argument of `build_record` has key and value which is same as default value of database, we should also except the key from `create_scope` in `initialize_attributes`. Because at first `build_record` initialize record object with argument of `build_record`, then assign attributes derived from Association's scope. In this case `record.changed` does not include the key, which value is same as default value of database, so we should add the key to except list. Fix #21893.