aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/query_methods.rb
Commit message (Collapse)AuthorAgeFilesLines
...
| * 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
| |
* | Merge branch 'master' into stmtAaron Patterson2013-05-171-0/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (330 commits) plugin new missing license spec let Ruby do the is_a check for us Mocha 0.14.0 was released with MT5 support. Switch back to gem Fix named routing regression from 3.2.13 Revert "just call the class method since we know the callbacks are stored at the" test refactor Add more data to AR::UnknownAttributeError Raise when multiple included blocks are defined Revert "Integration tests support the OPTIONS http method" restore whitespace in Gemfile between sqlite3 and sprockets Revert "Add the options method to action_controller testcase." Check if APP_RAKEFILE is defined Fix detection of engine in rake db:load_config Broken by d1d7c86d0c8dcb7e75a87644b330c4e9e7d6c1c1 Remove trailing line break tiny types should only be integers when the length is <= 1. fixes #10620 add failing test exposing mysql adapter tinyint bug require things we need Revert "Merge pull request #10600 from aditya-kapoor/code_refactor" just call the class method since we know the callbacks are stored at the class level this variable is used, so we don't have to use double assignments ...
| * added to rdoc for unscope that default_scope winsNeeraj Singh2013-05-031-0/+3
| |
* | Initial commit for select statements bindparam implementationNoemj2013-05-151-2/+33
|/
* When empty options passed to having clause having_values was [nil] but ↵Fyodor2013-04-231-1/+0
| | | | should be empty.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-04-111-2/+1
|\ | | | | | | | | Conflicts: guides/source/action_mailer_basics.md
| * mark relation mutator as :nodoc: [ci skip]Francesco Rodriguez2013-04-021-2/+1
| |
* | converge three lines into oneNeeraj Singh2013-04-101-3/+1
|/
* Fix some typos in AR- CHANGELOG, tests, method doc. fixedVipul A M2013-03-201-1/+1
|
* rename `Relation#uniq` to `Relation#distinct`. `#uniq` still works.Yves Senn2013-03-151-9/+11
| | | | | | | | The similarity of `Relation#uniq` to `Array#uniq` is confusing. Since our Relation API is close to SQL terms I renamed `#uniq` to `#distinct`. There is no deprecation. `#uniq` and `#uniq!` are aliases and will continue to work. I also updated the documentation to promote the use of `#distinct`.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-03-051-1/+1
|\
| * Fix WhereChain docs to mention only notErnie Miller2013-03-041-1/+1
| |
* | Remove .all usage from unscope doc examples [ci skip]Carlos Antonio da Silva2013-03-041-4/+4
| |
* | Use 1.9 hash style in changelog and doc examples [ci skip]Carlos Antonio da Silva2013-03-041-3/+3
| |
* | Created an unscope method for removing relations from a chain ofwangjohn2013-03-031-0/+94
|/ | | | | relations. Specific where values can be unscoped, and the unscope method still works when relations are merged or combined.
* Expand order(:symbol) to "table".symbol to prevent broken queries on PG.Yves Senn2013-02-251-0/+5
| | | | | | | | | | Fixes #9275. When `#order` is called with a Symbol this patch will prepend the quoted_table_name. Before the postgresql adapter failed to build queries containg a join and an order with a symbol. This expansion happens for all adapters.