| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
| |
attribute or method.
|
| |
|
| |
|
| |
|
|
|
|
| |
map to integers in the database, but can be queried by name
|
|
|
|
| |
Fixes: #12242, #9517, #10240
|
|
|
|
|
|
|
|
|
|
|
| |
Currently `scope_chain` uses same array for building different
`scope_chain` for different associations. During processing
these arrays are sometimes mutated and because of in-place
mutation the changed `scope_chain` impacts other reflections.
Fix is to dup the value before adding to the `scope_chain`.
Fixes #3882.
|
|
|
|
| |
Related issue: #11939, #12084
|
|
|
|
| |
side of a hm:t association along with preloading.
|
|\
| |
| | |
Make sure inverse_of is visible on the has_many callbacks
|
| | |
|
|/ |
|
|\
| |
| |
| |
| |
| |
| | |
Collapse where constraints to the Arel::Nodes::And node
Conflicts:
activerecord/CHANGELOG.md
|
| |
| |
| |
| |
| |
| |
| | |
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
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
change def self.primary_key to self.primary_key
change def self.primary_key to self.primary_key
|
|/ |
|
| |
|
|\
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
actionview/README.rdoc
activerecord/lib/active_record/migration.rb
guides/source/development_dependencies_install.md
guides/source/getting_started.md
|
| |
| |
| |
| |
| |
| |
| | |
This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing
changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9.
Seems to be a code merge done by mistake.
|
| |
| |
| |
| |
| | |
Currently, ActiveRecord models with multiple words cannot have their
inverse associations detected automatically.
|
| | |
|
|/ |
|
| |
|
|
|
|
|
|
| |
change def self.primary_key to self.primary_key
change def self.primary_key to self.primary_key
|
| |
|
| |
|
|
|
|
|
|
| |
association proxy
Closes #11248.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Method `delete_all` should not be invoking callbacks and this
feature was deprecated in Rails 4.0. This is being removed.
`delete_all` will continue to honor the `:dependent` option. However
if `:dependent` value is `:destroy` then the default deletion
strategy for that collection will be applied.
User can also force a deletion strategy by passing parameter to
`delete_all`. For example you can do `@post.comments.delete_all(:nullify)`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For example, you need to change this:
class Author < ActiveRecord::Base
has_many :posts
has_many :taggings, :through => :posts
end
class Post < ActiveRecord::Base
has_one :tagging
has_many :taggings
end
class Tagging < ActiveRecord::Base
end
To this:
class Author < ActiveRecord::Base
has_many :posts
has_many :taggings, :through => :posts, :source => :tagging
end
class Post < ActiveRecord::Base
has_one :tagging
has_many :taggings
end
class Tagging < ActiveRecord::Base
end
|
|
|
|
|
| |
of using +inverse_of: false+ option. Changing the documentation and
adding a CHANGELOG entry for the automatic inverse detection feature.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When removing records from a `has_many` association it used
the `primary_key` defined on the association.
Our test suite didn't fail because on all occurences of `:primary_key`,
the specified column was available in both tables. This prevented the
code from raising an exception but it still behaved badly.
I added a test-case to prevent regressions that failed with:
```
1) Error:
HasManyAssociationsTest#test_has_many_assignment_with_custom_primary_key:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: essays.first_name: UPDATE "essays" SET "writer_id" = NULL WHERE "essays"."writer_id" = ? AND "essays"."first_name" IS NULL
```
|
|
|
|
|
|
|
| |
According to
https://github.com/rails/rails/blob/b601399b72ab56cc01368f02615af99f45d1
4f02/activerecord/lib/active_record/counter_cache.rb#L14, u can pass
more then one association to the `reset_counters` method.
|
|
|
|
|
|
| |
the results. Added tests to check to make sure that inverse associations are
automatically found when has_many, has_one, or belongs_to associations
are defined.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
See #9869 and #9929.
The problem arises from the following example:
class Project < ActiveRecord::Base
scope :completed, -> { where completed: true }
end
class MajorProject < Project
end
When calling:
MajorProject.where(tasks_count: 10).completed
This expands to:
MajorProject.where(tasks_count: 10).scoping {
MajorProject.completed
}
However the lambda for the `completed` scope is defined on Project. This
means that when it is called, `self` is Project rather than
MajorProject. So it expands to:
MajorProject.where(tasks_count: 10).scoping {
Project.where(completed: true)
}
Since the scoping was applied on MajorProject, and not Project, this
fails to apply the tasks_count condition.
The solution is to make scoping apply across STI classes. I am slightly
concerned about the possible side-effects of this, but no tests fail and
it seems ok. I guess we'll see.
|
| |
|
|
|
|
| |
fixes #10016
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
PR #5210 added a Friendship model to illustrate a bug, but in doing so
created a confusing structure because both belongs_to declarations in
Friendship referred to the same side of the join. The new structure
maintains the integrity of the bug test while changing the follower
relationship to be more useful for other testing.
|
|
|
|
|
|
|
|
| |
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`.
|
|\
| |
| |
| |
| |
| |
| | |
Fix ActiveRecord `subclass_from_attrs` when eager_load is false.
Conflicts:
activerecord/CHANGELOG.md
|
| |
| |
| |
| |
| | |
It cannot find subclass because all classes are loaded automatically
when it needs.
|
|/
|
|
| |
Closes #9110
|