| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
Refactored ActiveRecord `first` method to get rid of duplication.
|
| | |
|
| | |
|
|\ \
| | |
| | |
| | |
| | | |
Conflicts:
guides/source/upgrading_ruby_on_rails.md
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
recommended
|
| | | |
|
| | | |
|
|\ \ \
| | | |
| | | | |
Rather than raising ThrowResult when construct_limited_ids_conditions comes up empty, set the relation to NullRelation and rely on its results.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
up empty, set the relation to NullRelation and rely on its results.
This will help avoid errors like 2fcafee250ee2, because in most cases NullRelation will do the right thing. Minor bonus is avoiding the use of exceptions for flow control.
|
| | | |
| | | |
| | | |
| | | | |
failing to construct_limited_ids_condition.
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Use grep instead of select with === in QueryMethods
|
| | | | |
| | | | |
| | | | |
| | | | | |
pass block directly to grep
|
|/ / / / |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | |
| | | |
| | | |
| | | | |
the time
|
| |/ /
|/| | |
|
|\ \ \
| |/ /
|/| |
| | |
| | | |
Conflicts:
activesupport/lib/active_support/callbacks.rb
|
| | | |
|
| | |
| | |
| | |
| | | |
#join_associations.
|
| | |
| | |
| | |
| | |
| | |
| | | |
is always a new object.
Thanks to the #except we call at the top of the method.
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
to pair it closely with its motivation.
|
| | |
| | |
| | |
| | | |
used at all on non-postgres adapters.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database:
With the model
class Topic
alias_attribute :heading, :title
end
The call
Topic.where(heading: 'The First Topic')
should yield the same result as
Topic.where(title: 'The First Topic')
This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`.
This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`.
Github #7839
*Godfrey Chan*
|
| | |
|
| |
| |
| |
| | |
should be empty.
|
|\ \
| | |
| | |
| | |
| | | |
Conflicts:
guides/source/action_mailer_basics.md
|
| | | |
|
| | |
| | |
| | |
| | | |
warning: `*' interpreted as argument prefix
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Fixes #3002. Also see #5494.
```
class Comment < ActiveRecord::Base
belongs_to :post
end
class Author < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
belongs_to :author
has_many :comments
end
```
`Comment.joins(:post).merge(Post.joins(:author).merge(Author.where(:name => "Joe Blogs"))).all` would
fail with `ActiveRecord::ConfigurationError: Association named 'author' was not found on Comment`.
It is failing because `all` is being called on relation which looks like this after all the merging:
`{:joins=>[:post, :author], :where=>[#<Arel::Nodes::Equality: ....}`. In this relation all the context that
`Post` was joined with `Author` is lost and hence the error that `author` was not found on `Comment`.
Ths solution is to build JoinAssociation when two relations with join information are being merged. And later
while building the arel use the previously built `JoinAssociation` record in `JoinDependency#graft` to
build the right from clause.
Thanks to Jared Armstrong (https://github.com/armstrjare) for most of the work. I ported it to make it
compatible with new code base.
|
| | | |
|
| | | |
|
|/ /
| |
| |
| |
| | |
inverse_of option. I've also refactored the code for raising a
RecordNotFound exception when searching for records with ids.
|