aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #24099 from k0kubun/preserve-readonlyRafael Mendonça França2016-08-181-2/+20
|\ | | | | | | Preserve readonly flag only for readonly association
| * Preserve readonly flag only for readonly associationTakashi Kokubun2016-07-301-2/+20
| | | | | | | | Fixes #24093
* | Merge pull request #26009 from kamipo/fix_inconsistent_finder_methods_signatureRafael França2016-08-171-9/+0
|\ \ | | | | | | Fix inconsistent the signature of finder methods for collection association
| * | Fix inconsistent the signature of finder methods for collection associationRyuta Kamizono2016-08-161-9/+0
| | | | | | | | | | | | | | | | | | | | | `#second`, `#third`, etc finder methods was added in 03855e790de2224519f55382e3c32118be31eeff. But the signature of these methods is inconsistent with the original finder methods. And also the signature of `#first` and `#last` methods is different from the original. This commit fixes the inconsistency.
* | | Merge pull request #26021 from ↵Rafael França2016-08-171-0/+40
|\ \ \ | | | | | | | | | | | | | | | | kamipo/finder_bang_method_should_call_non_bang_method Finder bang method should call non bang method
| * | | Finder bang method should call non bang methodRyuta Kamizono2016-08-161-0/+40
| |/ / | | | | | | | | | Otherwise CollectionProxy's bang methdos cannot respect dirty target.
* / / Fix count which would sometimes force a DISTINCTMaxime Lapointe2016-08-161-8/+17
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current behaviour of checking if there is a LEFT OUTER JOIN arel node to detect if we are doing eager_loading is wrong. This problem wasn't frequent before as only some pretty specific cases would add a LEFT OUTER JOIN arel node. However, the recent new feature left_outer_joins also add this node and made this problem happen frequently. Since in the perform_calculation function, we don't have access to eager_loading information, I had to extract the logic for the distinct out to the calculate method. As I was in the file for left_outer_join tests, I fixed a few that had bugs and I replaced some that were really weak with something that will catch more issues. In relation tests, the first test I changed would have failed if it had validated the hash returned by count instead of just checking how many pairs were in it. This is because this merge of join currently transforms the join node into an outer join node, which then made count do a distinct. So before this change, the return was {1=>1, 4=>1, 5=>1}.
* | Merge pull request #26097 from Dagnan/fix_recordnotfound_args_rebasedRafael França2016-08-161-0/+12
|\ \ | | | | | | When calling association.find RecordNotFound is now raised with the s…
| * | When calling association.find RecordNotFound is now raised with the same ↵Michel Pigassou2016-08-131-0/+12
| | | | | | | | | | | | argument as when we do it in Record.find (primary_key, id and model).
* | | Merge pull request #26162 from kamipo/take_respects_dirty_targetRafael França2016-08-161-4/+8
|\ \ \ | | | | | | | | `CollectionProxy#take` should respect dirty target
| * | | `CollectionProxy#take` should respect dirty targetRyuta Kamizono2016-08-141-4/+8
| |/ / | | | | | | | | | | | | `#first`, `#second`, ..., `#last` methods respects dirty target. But `#take` doesn't respect it. This commit fixes the inconsistent behavior.
* / / Add three new rubocop rulesRafael Mendonça França2016-08-1615-127/+127
|/ / | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | 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
| | |