aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #17421 from rails/warn-with-heredocXavier Noria2014-10-283-9/+22
|\ | | | | let warn with heredocs
| * let's warn with heredocsXavier Noria2014-10-283-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
* | Remove unneccessary default values from relation mergerSean Griffin2014-10-281-2/+2
| | | | | | | | The value methods will default to an empty array for us automatically
* | Call value methods when merging relations, rather than accessing keysSean Griffin2014-10-281-14/+14
|/ | | | | | | | The change to accessing keys directly was originally added to allow `merge` to take a hash. The implementation of `HashMerger` no longer requires us to be doing so. Accessing the values directly makes it impossible to change internal storage details, even if shim methods are added temporarily
* Allow Relation#rewhere to work with infinite range valuesDan Olson2014-10-271-1/+1
|
* Fix Relation.rewhere to work with Range valuesDan Olson2014-10-201-1/+1
|
* [ci skip] Make merge method nodocAnshul Sharma2014-10-201-8/+1
|
* [ci skip] merge docsAnshul Sharma2014-10-201-0/+7
|
* Remove duplicate error message "Couldn't find..."claudiob2014-10-131-6/+10
| | | | | | | | | This commit removes the duplication of the error message: > Couldn't find #{@klass.name} with [#{arel.where_sql}] introduced in #15791 by adding a private method `find_nth!` that deals with all the method like `first!` and `second!`.
* No need to call to_sym hereGodfrey Chan2014-09-202-9/+9
| | | | | The hash is now string-keyed, and [_]reflect_on_association calls `to_s` on the argument anyway.
* Merge pull request #15791 from zev/add_model_to_recordnotfound_messageAaron Patterson2014-09-191-8/+8
|\ | | | | Update RecordNotFound exception cases to include a message with the
| * Update RecordNotFound exception cases to include a message with theZev Blut2014-06-181-8/+8
| | | | | | | | Model that the Record was not found in.
* | A `NullRelation` should represent nothing. Closes #15176.Yves Senn2014-09-111-2/+2
| | | | | | | | | | | | [Matthew Draper & Yves Senn] Closes #16860. (pull request to discuss the implementation)
* | Fix query with nested array in Active RecordCristian Bica2014-09-061-4/+12
| | | | | | | | | | | | | | | | `User.where(id: [[1,2],3])` was equal to `User.where(id:[1, 2, 3])` in Rails 4.1.x but because of some refactoring in Arel this stopped working in 4.2.0. This fixes it in Rails. [Dan Olson & Cristian Bica]
* | Fixed regression with referencing polymorphic assoc in eager-loadGodfrey Chan2014-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | This is cased by 03118bc + 9b5d603. The first commit referenced the undefined local variable `column` when it should be using `reflection.type` as the lookup key. The second commit changed `build_arel` to not modify the `bind_values` in- place so we need to combine the arel's `bind_values` with the relation's when building the SQL. Fixes #16591 Related #15821 / #15892 / 7aeca50
* | always reorder bind parameters. fixes #15920Aaron Patterson2014-09-041-6/+4
| |
* | Avoid using heredoc for user warningsGodfrey Chan2014-08-281-4/+2
| | | | | | | | | | | | | | | | | | | | Using heredoc would enforce line wrapping to whatever column width we decided to use in the code, making it difficult for the users to read on some consoles. This does make the source code read slightly worse and a bit more error-prone, but this seems like a fair price to pay since the primary purpose for these messages are for the users to read and the code will not stick around for too long.
* | Fixes the `Relation#exists?` to work with polymorphic associations.Kassio Borges2014-08-181-1/+1
| | | | | | | | Fixes #15821.
* | Check attributes passed to create_with and whereRafael Mendonça França2014-08-181-2/+14
| | | | | | | | | | | | | | | | | | | | | | If the request parameters are passed to create_with and where they can be used to do mass assignment when used in combination with Relation#create. Fixes CVE-2014-3514 Conflicts: activerecord/lib/active_record/relation/query_methods.rb
* | Fixed AR::Relation#where edge case with Hash and other RelationBogdan Gusiev2014-08-141-3/+15
| | | | | | | | | | | | Example: Author.where(posts: { author_id: Author.where(country_id: 1) }).joins(:posts)
* | remove blank lines in the start of the ActiveRecord filesPonomarev Nikolay2014-07-291-1/+0
| |
* | Fix typo in commentCade Truitt2014-07-021-1/+1
| |
* | Encapsulate knowledge of type objects on `ActiveRecord::Result`Sean Griffin2014-06-221-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Attempting to reduce the number of places that care about the details of how type casting occurs. We remove the type casting of the primary key in `JoinDependecy`, rather than encapsulating it. It was originally added for consistency with https://github.com/rails/rails/commit/40898c8c19fa04442fc5f8fb5daf3a8bdb9a1e03#diff-06059df8d3dee3101718fb2c01151ad0R211, but that conditional was later removed in https://github.com/rails/rails/commit/d7ddaa530fd1b94e22d745cbaf2e8a5a34ee9734. What is important is that the same row twice will have the same value for the primary key, which it will.
* | Don't use `Column` for type casting in Relation calculationsSean Griffin2014-06-181-12/+8
| |
* | [ci skip] add API doc for AR Group.Aditya Kapoor2014-06-171-1/+9
| |
* | Pluck should work with columns of the same name from different tablesSean Griffin2014-06-111-3/+1
|/ | | | | | | | The column name given by the adapter doesn't include the table namespace, so going through the hashed version of the result set causes overridden keys. Fixes #15649
* ActiveRecord::FinderMethods.find passes proc parameter #15382James Yang2014-06-101-1/+1
|
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-2/+2
| | | | | | | | In some cases there is a difference between the two, we should always be doing one or the other. For convenience, `type_cast` is still a private method on type, so new types that do not need different behavior don't need to implement two methods, but it has been moved to private so it cannot be used accidentally.
* reuse available belongs_to? methodeileencodes2014-06-031-1/+1
| | | | | | | | | | Reflection has a `belongs_to?` method. Instead of checking for `macro == :belongs_to` throughout the source reuse existing method. I also bumped `foreign_key_present?` method onto on line because the `belongs_to?` makes it shorter than other longer lines in the same class.
* Remove unused `initialize_attributes` methodSean Griffin2014-06-021-1/+1
| | | | | This was previously a hook for a special case related to `serialize`, which has since been removed.
* Merge pull request #14834 from al2o3cr/issue14155Aaron Patterson2014-05-271-1/+10
|\ | | | | Correctly alias table names when joining more than once
| * WIP: pass existing joins to construct_join_dependencyMatt Jones2014-05-161-1/+10
| |
* | Allow empty arrays in where predicatesSean Griffin2014-05-261-0/+2
| |
* | Merge pull request #15300 from arthurnn/refactor_reflectionsRafael Mendonça França2014-05-262-3/+3
|\ \ | | | | | | Refactor reflections
| * | Merge pull request #15210 from arthurnn/fix_hbtm_reflectionArthur Neves2014-05-242-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Refactor the handling of arrays in where predicatesSean Griffin2014-05-261-11/+14
|/ / | | | | | | | | | | Simplifies the code slightly, isolates non-nil non-range values into a single array, which will make it easier to do things like apply type casting to them in the future.
* | Remove duplicated parameter check on #where!Sergey Alekseev2014-05-231-8/+4
| | | | | | | | | | | | | | | | | | | | It seems that #where! is not designed to be used as a chained where. See initial implementation at 8c2c60511beaad05a218e73c4918ab89fb1804f0. So, no need to check twice. We should not test #where! https://github.com/rails/rails/pull/15285#discussion_r13018316
* | Removed not-used codePaul Nikitochkin2014-05-221-1/+0
|/
* Merge pull request #15078 from nbudin/fix_merger_filter_binds_comparison_masterRafael Mendonça França2014-05-141-1/+1
|\ | | | | | | | | | | | | Make filter_binds filter out symbols that are equal to strings Conflicts: activerecord/CHANGELOG.md
| * Make filter_binds filter out symbols that are equal to stringsNat Budin2014-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord::Relation::Merger's filter_binds method does not filter out bind variables when one of the attribute nodes has a string name, but the other has a symbol name, even when those names are actually equal. This can result in there being more bind variables than placeholders in the generated SQL. This is particularly an issue for PostgreSQL, where this is treated as an error. This patch changes the filter_binds method to make it convert both attribute names to strings before comparing.
* | docs, explain usage of `count` + `select`. Closes #15065. [ci skip]Yves Senn2014-05-131-0/+8
|/
* Put back Relation#join method as a delegate to ArrayBogdan Gusiev2014-05-051-1/+1
| | | | | | | | This is a regression 4.0 -> 4.1 fix. In 4.1.0 Relation#join is delegated to Arel#SelectManager. In 4.0 series it is delegated to Array#join This patch puts back the behaviour of 4.0
* push up bind params on "simple" subquery calculationsAaron Patterson2014-05-021-2/+4
| | | | | bind parameters we not being propogated to simple subquery calculation calls. This fixes it
* Give real privacy to class methods in AR::PredicateBuilderHector Satre2014-05-011-7/+8
|
* Merge branch 'master' into adequaterecordAaron Patterson2014-04-254-5/+25
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (28 commits) move AR length validation tests into separate test-case. No need for trailing slash on migration path. reset `@arel` when modifying a Relation in place. PostgreSQL Timestamps always map to `:datetime`. [ci skip] Improve formatting and yml Fix a typo in the doc of forty_two AR FinderMethod Improve readability of contributing to rails guide. [ci skip] Precompile the image we're referencing, too. `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions. Fixed an issue with migrating legacy json cookies. Correct comment [ci skip] Perfer to define methods instead of calling test Fix syntax error Add CHANGELOG entry for #14757 [ci skip] Fix run-on sentences and improve grammar [skip ci] Add test for using ActionView::Helpers::FormHelper.label with block and html select! renamed to avoid name collision Array#select! Rearrange deck chairs on the titanic. Organize connection handling test cases. Change favicon_link_tag helper mimetype from image/vnd.microsoft.icon to image/x-icon. ActionController::Renderers documentation fix ...
| * reset `@arel` when modifying a Relation in place.Yves Senn2014-04-241-0/+12
| | | | | | | | /cc @tenderlove
| * Fix a typo in the doc of forty_two AR FinderMethodEric Bouchut2014-04-241-1/+1
| |
| * Merge pull request #14757 from estsauver/14752Rafael Mendonça França2014-04-223-4/+12
| |\ | | | | | | Fix behavior of select! to be consistent with select #14752
| | * select! renamed to avoid name collision Array#select!Earl J St Sauver2014-04-213-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | Fixes #14752 Select mimics the block interface of arrays, but does not mock the block interface for select!. This change moves the api to be a private method, _select!.
* | | Merge branch 'master' into adequaterecordAaron Patterson2014-04-201-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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