aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Make NullRelation a bit more like a real relation by returning 0 for ↵Ben Woosley2013-05-102-3/+8
| | | | #calculate(:count)
* No point in memoizing a simple literal string.Ben Woosley2013-05-101-1/+1
|
* Add coverage for the fact that pluck without an argument returns all the ↵Ben Woosley2013-05-101-0/+5
| | | | table's columns.
* Fix that #pluck wasn't rescuing ThrowResult, meaning it would blow up when ↵Ben Woosley2013-05-102-0/+8
| | | | failing to construct_limited_ids_condition.
* Merge pull request #10558 from Empact/cleanup-finder-methodsRafael Mendonça França2013-05-104-28/+25
|\ | | | | Cleanup finder methods
| * Extract JoinDependency#join_relation to DRY the repeated application of the ↵Ben Woosley2013-05-103-7/+9
| | | | | | | | #join_associations.
| * In #apply_join_dependency, we can apply the #where in-place because relation ↵Ben Woosley2013-05-101-1/+1
| | | | | | | | | | | | is always a new object. Thanks to the #except we call at the top of the method.
| * DRY-up join dependency creation by extracting construct_join_depdencyBen Woosley2013-05-101-7/+5
| |
| * Pull the excepts into apply_join_dependency, for the sake of DRY.Ben Woosley2013-05-101-3/+4
| |
| * Simplify conditions within apply_join_dependencyBen Woosley2013-05-101-9/+5
| |
| * Move the except(:select) inside the construct_limited_ids_condition method ↵Ben Woosley2013-05-101-2/+2
| | | | | | | | to pair it closely with its motivation.
| * Reject blank order_values within #columns_for_distinct, as the orders aren't ↵Ben Woosley2013-05-102-3/+3
|/ | | | used at all on non-postgres adapters.
* Move #proxy_association method to AssociationRelationJon Leighton2013-05-103-4/+6
|
* Merge pull request #6792 from Empact/postgres-distinctJon Leighton2013-05-105-12/+61
|\ | | | | Fix that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"
| * Fix that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"Ben Woosley2013-05-105-12/+61
| | | | | | | | | | | | | | | | | | | | | | | | The combination of a :uniq => true association and the #distinct call in #construct_limited_ids_condition combine to create invalid SQL, because we're explicitly selecting DISTINCT, and also sending #distinct on to AREL, via the relation#distinct_value. Rather than build a select distinct clause in #construct_limited_ids_condition, I set #distinct! and pass just the columns into the select statement. This requires introducing a #columns_for_distinct method to return the select columns but not the statement itself.
* | Merge pull request #10553 from dasch/dasch/dont-try-to-explain-select_dbXavier Noria2013-05-102-1/+6
|\ \ | | | | | | Don't try to EXPLAIN select_db calls
| * | Don't try to EXPLAIN select_db callsDaniel Schierbeck2013-05-102-1/+6
|/ /
* | Merge pull request #10543 from vipulnsward/to_sortCarlos Antonio da Silva2013-05-101-1/+1
|\ \ | | | | | | Can you improve the commit message a little bit? It's good to describe why the change is happening.
| * | sort => sort! on new arrayVipul A M2013-05-101-1/+1
| | |
* | | Set the inverse when association queries are refinedJon Leighton2013-05-104-1/+33
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suppose Man has_many interests, and inverse_of is used. Man.first.interests.first.man will correctly execute two queries, avoiding the need for a third query when Interest#man is called. This is because CollectionAssociation#first calls set_inverse_instance. However Man.first.interests.where("1=1").first.man will execute three queries, even though this is obviously a subset of the records in the association. This is because calling where("1=1") spawns a new Relation object from the CollectionProxy object, and the Relation has no knowledge of the association, so it cannot set the inverse instance. This commit solves the problem by making relations spawned from CollectionProxies return a new Relation subclass called AssociationRelation, which does know about associations. Records loaded from this class will get the inverse instance set properly. Fixes #5717. Live commit from La Conf! :sparkles:
* | Merge pull request #10510 from think602/masterXavier Noria2013-05-091-0/+1
|\ \ | |/ |/| [ci skip] document protect_against_forgery? method
| * [ci skip] document protect_against_forgery? methodWeston Platter2013-05-101-0/+1
| |
* | Merge pull request #10535 from vipulnsward/remove_varCarlos Antonio da Silva2013-05-091-1/+0
|\ \ | | | | | | remove redundant var
| * | remove redundant varVipul A M2013-05-091-1/+0
| | |
* | | Merge pull request #10536 from vipulnsward/fix_exp_warningCarlos Antonio da Silva2013-05-091-1/+0
|\ \ \ | | | | | | | | remove variable and fix warning
| * | | remove variable and fix warningVipul A M2013-05-091-1/+0
| |/ /
* | | Merge pull request #10531 from waseem/refactor_requireCarlos Antonio da Silva2013-05-091-4/+4
|\ \ \ | | | | | | | | Require different core extensions correctly.
| * | | Require different core extensions correctly.Waseem Ahmad2013-05-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | The begin rescue block is specifically to catch LoadError while loading i18n gem. Other core extensions, under active support, should be required outside of the begin rescue block.
* | | | Merge pull request #10532 from prathamesh-sonpatki/RailsXavier Noria2013-05-095-5/+5
|\ \ \ \ | |_|/ / |/| | | rails -> Rails [ci skip]
| * | | rails -> Rails [ci skip]Prathamesh Sonpatki2013-05-095-5/+5
|/ / /
* / / "rails" -> "Rails" [ci skip]Xavier Noria2013-05-092-4/+4
|/ /
* | Fix that JSON and XML exception responses should give the HTTP error message ↵Jeremy Kemper2013-05-082-4/+4
| | | | | | | | for their status, by default, not the message from the underlying exception
* | Merge pull request #10523 from neerajdotname/last-where-clause-winsJeremy Kemper2013-05-081-13/+12
|\ \ | | | | | | Extraction to enable fixing #10421
| * | extracted piece of code into a methodNeeraj Singh2013-05-081-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to fix #10421 I need to enable merge to take an option so that relations could be merged without making the last where condition to win. That fix would forever reside in 4-0-stable branch and would not be merged to master since using scope without lambda has been deprecated. In this commit I have extracted code into a method and I think it makes code look better. Hence the request to merge it in both master and 4-0-stable. If there is any concern then this code can be merged only in 4-0-stable and that would be fine too.
* | | use public send on the scope parametersAaron Patterson2013-05-081-1/+1
| | |
* | | add test for object conditional with scopeAaron Patterson2013-05-081-0/+19
| | |
* | | using strings as scopes is not used anywhere, so remove itAaron Patterson2013-05-081-1/+1
| | |
* | | adding a class conditional testAaron Patterson2013-05-081-0/+12
| | |
* | | adding tests for lambdas as conditionsAaron Patterson2013-05-082-1/+41
| | |
* | | Merge branch 'polycb'Aaron Patterson2013-05-081-22/+48
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * polycb: separate identification computation separate filters from source code if the callbacks are not the same class, they cannot be duplicates fix object comparison case polymorphic comparison operator
| * | | separate identification computationAaron Patterson2013-05-081-24/+18
| | | |
| * | | separate filters from source codeAaron Patterson2013-05-081-20/+31
| | | |
| * | | if the callbacks are not the same class, they cannot be duplicatesAaron Patterson2013-05-081-2/+6
| | | |
| * | | fix object comparison caseAaron Patterson2013-05-081-1/+5
| | | |
| * | | polymorphic comparison operatorAaron Patterson2013-05-081-11/+24
| | | |
* | | | Merge pull request #10524 from wangjohn/define_method_for_callbacksRafael Mendonça França2013-05-081-18/+12
|\ \ \ \ | |/ / / |/| | | Using define method instead of class eval when defining model callbacks.
| * | | Using define method instead of class eval when defining model callbacks.wangjohn2013-05-081-18/+12
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on my benchmark results, this change improves performance substantially when defining callbacks. This benchmark (https://gist.github.com/wangjohn/5542610) was run using the current master and also using my experimental branch which replaced class_eval with define_single_method. Using class_eval (current master): user system total real 10 trials 0.000000 0.000000 0.000000 ( 0.001568) 50 trials 0.020000 0.000000 0.020000 ( 0.021715) 500 trials 0.110000 0.000000 0.110000 ( 0.115357) 1000 trials 0.250000 0.000000 0.250000 ( 0.260025) 10000 trials 2.560000 0.000000 2.560000 ( 2.568408) 50000 trials 12.800000 0.010000 12.810000 ( 12.886871) Using define_single_method (experimental branch): user system total real 10 trials 0.000000 0.000000 0.000000 ( 0.000790) 50 trials 0.000000 0.000000 0.000000 ( 0.002960) 500 trials 0.050000 0.010000 0.060000 ( 0.055690) 1000 trials 0.100000 0.000000 0.100000 ( 0.094073) 10000 trials 0.890000 0.000000 0.890000 ( 0.900364) 50000 trials 4.650000 0.000000 4.650000 ( 4.686127)
* / / we need to indicate the type of callbackAaron Patterson2013-05-081-2/+2
|/ /
* | Merge pull request #10355 from burke/masterJeremy Kemper2013-05-081-39/+19
|\ \ | | | | | | Use Ruby's native Encoding functionality to implement `tidy_bytes`
| * | Use ruby's Encoding support for tidy_bytesBurke Libbey2013-05-081-39/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was quite slow. This leverages some of the transcoding abilities built into Ruby 1.9 instead. It is roughly 96% faster. The roundtrip through UTF_8_MAC here is because ruby won't let you transcode from UTF_8 to UTF_8. I chose the closest encoding I could find as an intermediate.