aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/query_methods.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* | remove dead codeAaron Patterson2014-01-141-2/+0
| |
* | we should not be copying these. fixes ↵Aaron Patterson2014-01-141-4/+0
| | | | | | | | test_find_all_using_where_with_relation_with_bound_values
* | fixing column alias resolutionAaron Patterson2014-01-131-1/+1
| |
* | do not clear out bind parameters on unscopeAaron Patterson2014-01-131-3/+0
| |
* | Merge branch 'master' into set_bindsAaron Patterson2014-01-131-4/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (24 commits) unscope should remove bind values associated with the where reverse_order_value= is not private, so no need to send avoid more dynamic symbols no need to to_sym recover from test runs that leave the database in a bad state updates screenshot data [ci skip] "serie" => "series" revises a few things in the getting started guide [ci skip] Favor canonical environment variables for secrets removed extra comma [ci skip] Only lookup `config.log_level` for stdlib `::Logger`. Closes #11665. Updated Changelog to reflect removal of :dependent => :restrict standardize on jruby_skip & rbx_skip fix bug in becomes! when changing from base to subclass. Closes #13272. highlight http://localhost:3000 in README.md. Closes #13643. [ci skip] doc proc/lambda arg on inclusion validation. Closes #13689. [ci skip] Skip Spring App Generator tests on JRuby fixes a typo in a CHANGELOG upgrade SDoc fixes the Gemfile generator templates ... Conflicts: activerecord/test/cases/hot_compatibility_test.rb
| * unscope should remove bind values associated with the whereAaron Patterson2014-01-131-0/+2
| |
| * reverse_order_value= is not private, so no need to sendAaron Patterson2014-01-131-1/+1
| | | | | | | | It's not public API, but is not private scoped.
| * avoid more dynamic symbolsAaron Patterson2014-01-131-1/+1
| |
| * no need to to_symAaron Patterson2014-01-131-2/+2
| |
* | adding bind values to the manager objectAaron Patterson2014-01-131-1/+1
| |
* | bubble bind parameters up when building join dependenciesAaron Patterson2014-01-131-2/+5
| |
* | Merge branch 'master' into set_bindsAaron Patterson2014-01-111-94/+127
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (2794 commits) doc, API example on how to use `Model#exists?` with multiple IDs. [ci skip] Restore DATABASE_URL even if it's nil in connection_handler test [ci skip] - error_messages_for has been deprecated since 2.3.8 - lets reduce any confusion for users Ensure Active Record connection consistency Revert "ask the fixture set for the sql statements" Check `respond_to` before delegation due to: https://github.com/ruby/ruby/commit/d781caaf313b8649948c107bba277e5ad7307314 Adding Hash#compact and Hash#compact! methods MySQL version 4.1 was EOL on December 31, 2009 We should at least recommend modern versions of MySQL to users. clear cache on body close so that cache remains during rendering add a more restricted codepath for templates fixes #13390 refactor generator tests to use block form of Tempfile Fix typo [ci skip] Move finish_template as the last public method in the generator Minor typos fix [ci skip] make `change_column_null` reversible. Closes #13576. create/drop test and development databases only if RAILS_ENV is nil Revert "Speedup String#to" typo fix in test name. [ci skip]. `core_ext/string/access.rb` test what we are documenting. Fix typo in image_tag documentation ... Conflicts: activerecord/lib/active_record/associations/join_dependency/join_association.rb activerecord/lib/active_record/relation/query_methods.rb
| * raise `ArgumentError` exception if `Model.where.not` is called with `nil` ↵Kuldeep Aggarwal2013-12-301-0/+2
| | | | | | | | argument
| * fix default select when from is usedCody Cutrer2013-12-191-1/+3
| |
| * #none documentation updated [ci skip]Akshay Vishnoi2013-12-181-5/+4
| |
| * Spelling and Grammar check [ci skip]Akshay Vishnoi2013-12-161-2/+2
| |
| * Merge remote-tracking branch 'docrails/master'Xavier Noria2013-11-241-4/+4
| |\ | | | | | | | | | | | | | | | Conflicts: activesupport/lib/active_support/core_ext/hash/deep_merge.rb activesupport/lib/active_support/core_ext/hash/keys.rb
| | * Change syntax format for example returned valuesPrem Sichanugrist2013-11-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | According to our guideline, we leave 1 space between `#` and `=>`, so we want `# =>` instead of `#=>`. Thanks to @fxn for the suggestion. [ci skip]
| * | Fix ActiveRecord::Relation#unscopeJon Leighton2013-11-201-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm pretty confused about the addition of this method. The documentation says that it was intended to allow the removal of values from the default scope (in contrast to #except). However it behaves exactly the same as except: https://gist.github.com/jonleighton/7537008 (other than having a slightly enhanced syntax). The removal of the default scope is allowed by 94924dc32baf78f13e289172534c2e71c9c8cade, which was not a change we could make until 4.1 due to the need to deprecate things. However after that change #unscope still gives us nothing that #except doesn't already give us. However there *is* a desire to be able to unscope stuff in a way that persists across merges, which would allow associations to be defined which unscope stuff from the default scope of the associated model. E.g. has_many :comments, -> { unscope where: :trashed } So that's what this change implements. I've also corrected the documentation. I removed the guide references to #except as I think unscope really supercedes #except now. While we're here, there's also a potential desire to be able to write this: has_many :comments, -> { unscoped } However, it doesn't make sense and would not be straightforward to implement. While with #unscope we're specifying exactly what we want to be removed from the relation, with "unscoped" we're just saying that we want it to not have some things which were added earlier on by the default scope. However in the case of an association, we surely don't want *all* conditions to be removed, otherwise the above would just become "SELECT * FROM comments" with no foreign key constraint. To make the above work, we'd have to somehow tag the relation values which get added when evaluating the default scope in order to differentiate them from other relation values. Which is way too much complexity and therefore not worth it when most use cases can be satisfied with unscope. Closes #10643, #11061.
| * | use arel nodes to represent non-string `order_values`.Yves Senn2013-11-191-19/+11
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug when merging relations of different classes. ``` Given: Post.joins(:author).merge(Author.order(name: :desc)).to_sql Before: SELECT "posts".* FROM "posts" INNER JOIN "authors" ON "authors"."id" = "posts"."author_id" ORDER BY "posts"."name" DESC After: SELECT "posts".* FROM "posts" INNER JOIN "authors" ON "authors"."id" = "posts"."author_id" ORDER BY "authors"."name" DESC ```
| * Added ActiveRecord::QueryMethods#rewhere which will overwrite an existing, ↵David Heinemeier Hansson2013-11-021-0/+12
| | | | | | | | named where condition.
| * unscope now works on default_scope after ↵Rafael Mendonça França2013-11-021-3/+0
| | | | | | | | 94924dc32baf78f13e289172534c2e71c9c8cade
| * Merge branch 'master' into joindepAaron Patterson2013-10-211-1/+8
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (23 commits) Escape the parentheses in the default function regexp Update docs on Tilt::Template in Asset Pipeline guide Fix loading a sql structure file on postgres when the file's path has whitespace in it remove trailing whitespace added with b057765 [ci skip]. Allow unscope to work with `where.not` Raise an exception when model without primary key calls .find_with_ids Process sub-query relation's binding values Instrument the generation of Action Mailer messages Remove extra variable creation and merge. In Relation#empty? use #exists? instead of #count. [ci skip] avoid deprecation warning in sample code Convert Fixnum into String the port number in MySQL Fix some indentation on autosave association Make define_non_cyclic_method simpler Add Sass gobbling info to asset pipeline docs Ensure the state is clean after one failure Fix typo in form_helper.rb add a new local variable to track if digests are being stored, to ensure the cleanup works correctly [ci skip] Fix number of methods added by association. update digestor code based on review ...
| | * Merge pull request #12588 from jetthoughts/12586_subquery_with_unprepared_sqlRafael Mendonça França2013-10-211-0/+7
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | Inline bind values for sub-queries generated for Relation in where Conflicts: activerecord/CHANGELOG.md
| | | * Process sub-query relation's binding valuesPaul Nikitochkin2013-10-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generated sub-query for Relation as array condition for `where` method did not take in account its bind values, in result generates invalid SQL query. Fixed by adding sub-query relation's binding values to base relation Closes: #12586
| | * | Allow unscope to work with `where.not`Eric Hankins2013-10-211-1/+1
| | |/ | | | | | | | | | | | | | | | Allows you to call #unscope on a relation with negative equality operators, i.e. Arel::Nodes::NotIn and Arel::Nodes::NotEqual that have been generated through the use of where.not.
| * / pass the outer joins to join_constraintsAaron Patterson2013-10-201-5/+1
| |/
| * merge JoinDependency as outer joinsAaron Patterson2013-10-101-1/+1
| | | | | | | | Merge JoinDependency objects as outer joins
| * stuff the join dependency object in the "anything goes" hash.Aaron Patterson2013-10-101-2/+4
| |
| * stop splatting things back and forthAaron Patterson2013-10-101-1/+1
| |
| * hide join_constraints inside the JoinDependency objectAaron Patterson2013-10-091-2/+1
| |
| * Merge pull request #12011 from jetthoughts/11963_fix_join_with_association_scopeRafael Mendonça França2013-09-161-6/+5
| |\ | | | | | | | | | | | | | | | | | | Collapse where constraints to the Arel::Nodes::And node Conflicts: activerecord/CHANGELOG.md
| | * Collapse where constraints to one where constraintPaul Nikitochkin2013-09-131-6/+5
| | | | | | | | | | | | | | | | | | | | | In order to remove duplication with joining arel where constraints with `AND`, all constraints on `build_arel` are collapsed into one head node: `Arel::Nodes::And` Closes: #11963
| * | Allow Relation#from to accept other relations with bind values.Ryan Wallace2013-09-081-0/+1
| |/
| * Extracted from `order` processing of arguments, and use it for `reorder` to ↵Paul Nikitochkin2013-09-041-13/+16
| | | | | | | | be consistent.
| * Minor optimization and code cleanup in query_methods.Eugene Gilburg2013-07-311-38/+45
| | | | | | | | | | | | | | | | - Use symbols rather than strings where possible to avoid extra object construction - Use destructive methods where possible to avoid extra object construction - Use array union rather than concat followed by uniq - Use shorthand block syntax where possible - Use consistent multiline block styles, method names, method parenteses style, and spacing
| * Revert change on ActiveRecord::Relation#order method that prepends newRafael Mendonça França2013-07-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | order on the old ones The previous behavior added a major backward incompatibility since it impossible to have a upgrade path without major changes on the application code. We are taking the most conservative path to be consistent with the idea of having a smoother upgrade on Rails 4. We are reverting the behavior for what was in Rails 3.x and, if needed, we will implement a new API to prepend the order clauses in Rails 4.1.
| * Improve ActiveRecord::QueryMethods#includes docsHenrik Hodne2013-07-171-0/+8
| | | | | | | | | | | | | | | | It's not immediately clear whether you can pass in multiple relations or not. After going through the code a bit, I saw that the arguments are just appended to an array. Also, added nested relations example. [ci skip]
| * decouple the manager class from building join constraintsAaron Patterson2013-07-161-4/+5
| |
| * save another array allocationAaron Patterson2013-07-151-1/+1
| |
| * removing useless assingmentAaron Patterson2013-07-151-1/+1
| |
| * use arel rather than slapping together SQL stringsAaron Patterson2013-07-151-2/+4
| |
| * Blacklist->whitelist for reference scans in order!Ernie Miller2013-07-141-1/+1
| | | | | | | | | | | | Stop special-casing Arel::Nodes as exempt from reference scanning in order. Instead, only scan order values that are strings for a table reference.
| * resolve aliases before passing the hash to the predicate builderAaron Patterson2013-07-021-0/+1
| |
| * Simplify/fix implementation of default scopesJon Leighton2013-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was necessary in order to support stuff like: class Post < ActiveRecord::Base default_scope where(published: true) scope :ordered, order("created_at") end If we didn't evaluate the default scope at the last possible moment before sending the SQL to the database, it would become impossible to do: Post.unscoped.ordered This is because the default scope would already be bound up in the "ordered" scope, and therefore wouldn't be removed by the "Post.unscoped" part. In 4.0, we have deprecated all "eager" forms of scopes. So now you must write: class Post < ActiveRecord::Base default_scope { where(published: true) } scope :ordered, -> { order("created_at") } end This prevents the default scope getting bound up inside the "ordered" scope, which means we can now have a simpler/better/more natural implementation of default scoping. A knock on effect is that some things that didn't work properly now do. For example it was previously impossible to use #except to remove a part of the default scope, since the default scope was evaluated after the call to #except.
| * flatten merged join_values before building the joinsNeeraj Singh2013-06-221-1/+1
| | | | | | | | | | | | | | | | fixes #10669 While joining_values special treatment is given to string values. By flattening the array it ensures that string values are detected as strings and not arrays.
| * Merge pull request #10767 from jmondo/masterCarlos Antonio da Silva2013-05-291-1/+1
| |\ | | | | | | Use grep instead of select with === in QueryMethods
| | * use grep over select for consistency and efficiencyJohn Gesimondo2013-05-281-1/+1
| | | | | | | | | | | | pass block directly to grep
| * | `implicit_readonly` is being removed in favor of calling `readonly` explicitlyYves Senn2013-05-271-5/+0
| |/
* | push binds through relation objectsAaron Patterson2013-05-201-1/+1
| |