aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* | Revert "Merge pull request #9207 from dylanahsmith/mysql-quote-numeric"Steve Klabnik2013-02-271-5/+0
|/ | | | | This reverts commit 408227d9c5ed7de26310d72a1a99c1ee02311c63, reversing changes made to dca0b57d03deffc933763482e615c3cf0b9a1d97.
* 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.
* Make explicit the method will raise an exceptionRafael Mendonça França2013-02-241-10/+10
| | | | Taking the wise advice of @carlosantoniodasilva
* remove AR auto-explain (config.auto_explain_threshold_in_seconds)Yves Senn2013-02-241-1/+1
| | | | | | | | | | We discussed that the auto explain feature is rarely used. This PR removes only the automatic explain. You can still display the explain output for any given relation using `ActiveRecord::Relation#explain`. As a side-effect this should also fix the connection problem during asset compilation (#9385). The auto explain initializer in the `ActiveRecord::Railtie` forced a connection.
* adds a missing LIMIT 1 in #take docsXavier Noria2013-02-231-1/+1
|
* Merge pull request #9345 from ↵Rafael Mendonça França2013-02-201-10/+10
|\ | | | | | | | | wangjohn/change_name_of_query_method_argument_checker_for_clarity Renaming the check_empty_arguments method to something more descriptive.
| * Renaming the check_empty_arguments method to something more descriptive.wangjohn2013-02-201-10/+10
| | | | | | | | | | The function is now called has_arguments? so that it's easier to tell that it's just checking to see if the args are blank or not.
* | removes some remaining relation bang methods documentation [ci skip]Xavier Noria2013-02-201-3/+0
| |
* | adds an example in the docs of #not with multiple conditions [ci skip]Xavier Noria2013-02-201-4/+8
|/
* Added comments about the check_empty_arguments method which is calledwangjohn2013-02-201-11/+27
| | | | | for query methods in a where_clause. Also, modified the CHANGELOG entry because it had false information and added tests.
* Raise an error when query methods have blank arguments, and when blank ↵John J Wang2013-02-191-9/+23
| | | | arguments are meaningless.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-02-152-0/+24
|\ | | | | | | | | Conflicts: guides/source/upgrading_ruby_on_rails.md
| * copy edits [ci skip]Vijay Dev2013-02-151-1/+1
| |
| * Add example for ActiveRecord::Base.joins using a string as argumentMaurizio De Santis2013-02-071-0/+5
| |
| * Add example for ActiveRecord::Base.group using a string as argumentMaurizio De Santis2013-02-071-0/+3
| |
| * Add documentation for ActiveRecord.select when use strings as argumentsMaurizio De Santis2013-02-071-0/+10
| |
| * Add ActiveRecord.count documentation when used on group relationsMaurizio De Santis2013-02-071-0/+6
| |
* | Use IN operator like arel for empty hash in where clauserobertomiranda2013-02-091-1/+1
| |
* | Reverting e170014113 (Change behaviour with empty hash in where clause)Guillermo Iguaran2013-02-081-1/+1
| |
* | Reverting 16f6f25 (Change behaviour with empty array in where clause)Guillermo Iguaran2013-02-081-2/+0
| |
* | Change behaviour with empty array in where clauserobertomiranda2013-02-081-0/+2
| |
* | Change behaviour with empty hash in where clauserobertomiranda2013-02-081-1/+1
| |
* | active_record: Quote numeric values compared to string columns.Dylan Smith2013-02-071-0/+5
|/
* Prevent Relation#merge from collapsing wheres on the RHSJon Leighton2013-01-271-17/+19
| | | | | | | | | | | | | | | | | | | | | | | This caused a bug with the new associations implementation, because now association conditions are represented as Arel nodes internally right up to when the whole thing gets turned to SQL. In Rails 3.2, association conditions get turned to raw SQL early on, which prevents Relation#merge from interfering. The current implementation was buggy when a default_scope existed on the target model, since we would basically end up doing: default_scope.merge(association_scope) If default_scope contained a where(foo: 'a') and association_scope contained a where(foo: 'b').where(foo: 'c') then the merger would see that the same column is representated on both sides of the merge and collapse the wheres to all but the last: where(foo: 'c') Now, the RHS of the merge is left alone. Fixes #8990
* `#count` in conjunction with `#uniq` performs distinct count.Yves Senn2013-01-261-1/+2
| | | | closes #6865
* reduce the number of queries on IN clauses, fix relation queries in `where`Aaron Patterson2013-01-242-1/+6
|
* stop converting strings to symbolsAaron Patterson2013-01-241-1/+1
|
* Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"Guillermo Iguaran2013-01-181-1/+1
| | | | | This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
* User Rails 4 find_byrobertomiranda2013-01-181-1/+1
|
* Refactor predicate builder when receiving empty hashCarlos Antonio da Silva2013-01-171-4/+4
| | | | | | | There's no need to create a new arel table or reflect on the column association if the value is empty, these attributes are not used. Also no need to concat a new array, just append the query value.
* These are already required through AS/railsAkira Matsuda2013-01-072-3/+0
| | | | | | * dependencies/autoload * concern * deprecation
* refatctoring of some code repetition in spawn_methodsAngelo capilleri2012-12-311-8/+10
|
* warning removed: shadowing outer local variableArun Agrawal2012-12-301-2/+2
|
* fix time typcasting on group counts in PGAaron Patterson2012-12-281-2/+5
|
* mysql does not return alias names, so fall backAaron Patterson2012-12-281-4/+10
|
* fix PG typecasting errorsAaron Patterson2012-12-281-2/+5
|
* Replace some global Hash usages with the new thread safe cache.thedarkone2012-12-141-22/+16
| | | | | | | | | | | | | | | | Summary of the changes: * Add thread_safe gem. * Use thread safe cache for digestor caching. * Replace manual synchronization with ThreadSafe::Cache in Relation::Delegation. * Replace @attribute_method_matchers_cache Hash with ThreadSafe::Cache. * Use TS::Cache to avoid the synchronisation overhead on listener retrieval. * Replace synchronisation with TS::Cache usage. * Use a preallocated array for performance/memory reasons. * Update the controllers cache to the new AS::Dependencies::ClassCache API. The original @controllers cache no longer makes much sense after @tenderlove's changes in 7b6bfe84f3 and f345e2380c. * Use TS::Cache in the connection pool to avoid locking overhead. * Use TS::Cache in ConnectionHandler.
* Improve where.not docs [ci skip]Carlos Antonio da Silva2012-12-081-14/+8
| | | | | | | * Fix example queries * Remove doc entries of where.like/not_like. * Remove :chain from where.not related docs. To me that's an implementation detail and we don't expect people to use where(:chain).not.
* Rollback where.like and where.not_likeCarlos Antonio da Silva2012-12-071-26/+0
| | | | | | | | | | | | | | | | | | | The real win with these chain methods is where.not, that takes care of different scenarios in a graceful way, for instance when the given value is nil. where("author.id != ?", author_to_ignore.id) where.not("author.id", author_to_ignore.id) Both where.like and where.not_like compared to the SQL versions doesn't seem to give us that much: Post.where("title LIKE 'ruby on%'") Post.where.like(title: 'ruby on%'") Post.where("title NOT LIKE 'ruby on%'") Post.where.not_like(title: 'ruby on%'") Thus Rails is adding where.not, but not where.like/not_like and others.
* Document the types of arguments accepted by AR#notclaudiob2012-12-071-2/+11
| | | | | | | | This commit stems from https://github.com/rails/rails/pull/8332#issuecomment-11127957 Since the formats in which conditions can be passed to `not` differ from the formats in which conditions can be passed to `like` and `not_like`, then I think it's worth adding rdoc and tests to show this behavior
* Fix where.not with in clauseCarlos Antonio da Silva2012-12-071-3/+3
| | | | | | Arel::Nodes::In inherits from Arel::Nodes::Equality, so the case statement was always using the Equality operator for both scenarios, resulting in a not equal query instead.
* Update #where rdoc to match 6ba0f97 [ci skip]claudiob2012-12-071-4/+4
| | | | | | | | This commit updates the rdoc of AR#where to match the changes applied in https://github.com/rails/rails/commit/6ba0f97 that is: * `where(nil)` has the same effect of `where('')`: a no op * `where` (no args) has the same effect of `where(:chain)`: to create a WhereChain
* Ensure there won't be any regression with where(nil) callsCarlos Antonio da Silva2012-12-071-4/+4
| | | | | | | | | | | | | | | | | | | Consider this scenario: if params[:foo] conditions = { foo: true } end foos = Foo.where(conditions).order(:id) When params[:foo] is nil, this would call: foos = Foo.where(nil).order(:id) In this scenario, we want Foo.where(conditions) to be the same as calling Foo.all, otherwise we'd get a "NoMethodError order for WhereChain". Related to #8332.
* Merge pull request #8332 from amatsuda/ar_where_chainCarlos Antonio da Silva2012-12-071-7/+98
|\ | | | | | | | | | | | | | | Relation.where with no args can be chained with not, like, and not_like Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/query_methods.rb
| * Relation.where with no args can be chained with not, like, and not_likeAkira Matsuda2012-11-301-7/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | examples: Model.where.not field: nil #=> "SELECT * FROM models WHERE field IS NOT NULL Model.where.like name: 'Jeremy%' #=> "SELECT * FROM models WHERE name LIKE 'Jeremy%' this feature was originally suggested by Jeremy Kemper https://github.com/rails/rails/pull/5950#issuecomment-5591330 Closes #5950