aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
Commit message (Collapse)AuthorAgeFilesLines
* Don't rely on the column for type casting reflectionsSean Griffin2014-06-181-2/+2
|
* Merge pull request #15343 from dontfidget/fix_polymorphic_automatic_inverse_ofRafael Mendonça França2014-06-131-1/+1
|\ | | | | prevent bad automatic inverse_of association
| * use name specified by 'as' for automatic inverse association to avoid ↵Andrew S. Brown2014-06-101-1/+1
| | | | | | | | reflecting on wrong association
* | Merge pull request #15630 from eileencodes/refactor-join-keys-on-add_constraintsMatthew Draper2014-06-121-0/+17
|\ \ | | | | | | begin refactoring add_constraints by moving join keys
| * | begin refactoring add_constraints by moving join keyseileencodes2014-06-101-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add_constraints is complicated and difficult to read. This is the beginning of a long process of refactoring this code. First step: moved the join keys out of AssociationScope and into reflection. We then don't need to call `reflection` because now reflection is `self`. `foreign_key` must be named something else because reflection already has a `foreign_key` method and when passed into `JoinKeys` it was getting the wrong assignment. `reflection_foreign_key` seemed to be an appropriate name. I also named `key` `reflection_key` to match `reflection_foreign_key`.
* | | Add has_one? docs [skip ci]Arthur Neves2014-06-111-0/+1
|/ /
* | Use HasAndBelongsToMany instead of HABTMArthur Neves2014-06-091-1/+1
| |
* | reuse available collection? check instead of macroeileencodes2014-06-091-1/+1
| | | | | | | | | | | | | | Reflection has an available method that is used to check if the reflection is a collection. Any :has_many macro is considered a collection and `collection?` should be used instead of `macro == :has_many`.
* | Merge pull request #15596 from eileencodes/add-has_one-method-and-reuseRafael Mendonça França2014-06-091-1/+5
|\ \ | | | | | | add has_one? method and reuse instead of checking macro
| * | add has_one? method and reuse instead of checking macroeileencodes2014-06-091-1/+5
| | | | | | | | | | | | | | | | | | Instead of checking for `macro == :has_one` throughout the codebase we can create a `has_one?` method to match the `belongs_to?`, `polymorphic?` and other methods.
* | | Abstract away use of HABTM macroeileencodes2014-06-091-1/+8
|/ / | | | | | | | | | | | | | | | | By having the `:has_and_belongs_to_many` macro in the `@collection` we are punishing `:has_many` associations because it has to allocate the array and check the macro. @collection is returned to `macro == :has_many` and a new reflection class `HABTMReflection` is created to handle this case instead.
* | fix polymorphic? method and reuse iteileencodes2014-06-021-8/+8
| | | | | | | | | | | | Fix polymorphic to check for `options[:polymorphic]` instead of `options.key? :polymorphic` and then reuse the method `polymorphic?` method instead of constantly checking the same `options[:polymorphic]`.
* | Refactoring .reflections public method.Arthur Neves2014-05-261-4/+23
| | | | | | | | | | | | Now the internal reflections will hold a reference to its public representation, so when the outside world calls `Account.reflection` we can build a list of public reflections.
* | Use .to_s on _reflections lookupArthur Neves2014-05-241-1/+1
| |
* | Merge pull request #15210 from arthurnn/fix_hbtm_reflectionArthur Neves2014-05-241-7/+20
|/ | | | | | | | | Fix habtm reflection Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/counter_cache.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/reflection_test.rb
* deprecate, join, preload, eager load of instance dependent associations.Yves Senn2014-05-101-0/+14
| | | | | | | Closes #15024. These operations happen before instances are created. The current behavior is misleading and can result in broken behavior.
* Refactor AssociationScope#get_bind_valuesEric Chahin2014-05-051-0/+5
| | | | Added #join_id_for(owner) to reflection to avoid accessing the source_macro
* use statement cache for belongs_to relationsAaron Patterson2014-04-221-1/+4
|
* Merge branch 'master' into adequaterecordAaron Patterson2014-04-201-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (74 commits) [ci skip] builtin -> built-in Fix code indentation and improve formatting Grammar fix in Getting Started Guide Make URL escaping more consistent Optimize URI escaping Always escape string passed to url helper. Remove statement assuming coffee shop/public space wifi is inherently insecure Don't rely on Arel master in bug report template [ci skip] wrap methods in backticks [ci skip] "subhash" --> "sub-hash" multibyte_conformance.rb --> multibyte_conformance_test.rb Fix inconsistent behavior from String#first/#last `@destroyed` should always be set to `false` when an object is duped. remove warning `warning: ambiguous first argument; put parentheses or even spaces` :uglify -> :uglifier Regression test for irregular inflection on has_many Singularize association names before camelization Fix spelling and proper nouns Optimize select_value, select_values, select_rows and dry up checking whether to exec with cache for Postgresql adapter Include default rails protect_from_forgery with: :exception ... Conflicts: activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
| * Singularize association names before camelizationJavier Goizueta2014-04-181-2/+2
| | | | | | | | So that irregular multi-word pluralization rules have to be defined only for snake-case strings.
* | oops. should probably double check in the DCLAaron Patterson2014-04-141-1/+3
| |
* | cache scope building on associationsAaron Patterson2014-04-141-0/+9
|/ | | | SQL statements for querying associations are now cached
* Only call uniq on the conditional that actually needs itCarlos Antonio da Silva2014-04-091-1/+1
|
* Remove extra collect callCarlos Antonio da Silva2014-04-091-1/+1
|
* Make the aggregate_reflections cache work with strings as its keys.Lauro Caetano2014-04-091-2/+2
|
* No need to call `to_sym` on reflection name, since the cache now worksLauro Caetano2014-04-091-2/+2
| | | | | | with strings with string keys. Related #14668.
* Make the reflections cache work with strings as its keys.Lauro Caetano2014-04-091-2/+2
|
* The `source` option for `has_many => through` should accept StringLauro Caetano2014-04-091-1/+1
| | | | | | | | values. With the changes introduced by 16b70fddd4dc7e7fb7be108add88bae6e3c2509b it was expecting the value to be a Symbol, while it could be also a String value.
* Ensure we are returning either `true` or `false` for `#==`Godfrey Chan2014-03-291-1/+1
| | | | | | 460eb83d cused `ActiveRecord::Base#==` to sometimes return `nil` in some cases, this ensures we always return a boolean value. Also fixed a similar problem in AR reflections.
* scope_chain should not be mutated for other reflectionsNeeraj Singh2013-10-141-1/+1
| | | | | | | | | | | Currently `scope_chain` uses same array for building different `scope_chain` for different associations. During processing these arrays are sometimes mutated and because of in-place mutation the changed `scope_chain` impacts other reflections. Fix is to dup the value before adding to the `scope_chain`. Fixes #3882.
* Fix the indentationRafael Mendonça França2013-10-081-12/+13
|
* remove HABTM special cases from reflectionsAaron Patterson2013-10-021-14/+2
|
* push constructable? on to the reflectionAaron Patterson2013-10-021-0/+16
|
* Remove conditional adding a new methodRafael Mendonça França2013-09-111-5/+5
| | | | | | At the point we want to add the reflection we already know the reflection is of the AggregateReflection type so we can call a specific method
* support anonymous classes on has_many associationsAaron Patterson2013-09-031-0/+1
|
* pk should not be required for hm:t associationsAaron Patterson2013-08-291-1/+0
|
* Fixing multi-word automatic inverse detection.wangjohn2013-08-151-2/+2
| | | | | Currently, ActiveRecord models with multiple words cannot have their inverse associations detected automatically.
* Revert "all `scope_chain` methods allocate new arrays, no need to dup"Aaron Patterson2013-07-311-1/+1
| | | | This reverts commit 1468a4b89aa4bca99160bfa03572b2c0ab348db5.
* all `scope_chain` methods allocate new arrays, no need to dupAaron Patterson2013-07-301-1/+1
|
* oops!Aaron Patterson2013-07-231-1/+1
|
* eliminate conditional in JoinHelperAaron Patterson2013-07-231-1/+1
|
* acually get the actual source reflection :cry::gun:Aaron Patterson2013-07-231-7/+14
|
* factory methods should not have side effects.Aaron Patterson2013-07-231-3/+1
| | | | Move model mutation to the methods that are called on the model.
* extract mutation from generation methodAaron Patterson2013-07-231-3/+5
|
* habtm can only ever be an association reflectionAaron Patterson2013-07-221-2/+4
|
* use the predicate methodAaron Patterson2013-07-221-1/+1
|
* AR::Base does not need to know how to create reflection objectsAaron Patterson2013-07-221-19/+19
|
* use the superclass implementationAaron Patterson2013-07-181-1/+3
|
* quoted table name is also cachedAaron Patterson2013-06-131-1/+1
|
* table name is cached on the class, so stop caching twiceAaron Patterson2013-06-131-1/+1
|