| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
| |
[ci skip]
|
| |
|
|\
| |
| |
| | |
When .find_each is called without a block, return an Enumerator.
|
| |
| |
| |
| | |
This lets us do things like call: .find_each.with_index
|
|\ \
| | |
| | |
| | | |
Change Result#each to return an Enumerator when called without a block.
|
| | |
| | |
| | |
| | | |
As with #10992, this lets us call #with_index, etc on the results.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
currently `post.comments.find(Comment.first.id)` would load all
comments for the given post to set the inverse association.
This has a huge performance penalty. Because if post has 100k
records and all these 100k records would be loaded in memory
even though the comment id was supplied.
Fix is to use in-memory records only if loaded? is true. Otherwise
load the records using full sql.
Fixes #10509
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This reverts commit 2b817a5e89ac0e7aeb894a40ae7151a0cf3cef16, reversing
changes made to 353a398bee68c5ea99d76ac7601de0a5fef6f4a5.
Conflicts:
activerecord/CHANGELOG.md
Reason: the build broke
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
If I have a query that produces sql
`WHERE "users"."name" = 'a b'` then in the log all the
whitespace is being squeezed. So the sql that is printed in the
log is `WHERE "users"."name" = 'a b'`.
This can be confusing. This commit fixes it by ensuring that
whitespace is not squeezed.
fixes #10982
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
currently `post.comments.find(Comment.first.id)` would load all
comments for the given post to set the inverse association.
This has a huge performance penalty. Because if post has 100k
records and all these 100k records would be loaded in memory
even though the comment id was supplied.
Fix is to use in-memory records only if loaded? is true. Otherwise
load the records using full sql.
Fixes #10509
|
| |
| |
| |
| | |
b483a0d2a75b
|
|/
|
|
| |
the changelog.
|
|
|
|
|
|
|
|
| |
As you can also configure your database connection using `ENV["DATABASE_URL"]`,
the fixture setup can't reply on the `.configurations` Hash.
As the fixtures are only loaded when ActiveRecord is actually used
(`rails/test_help.rb`) it should be safe to drop the check for an existing configuration.
|
| |
|
| |
|
|\
| |
| |
| |
| | |
Conflicts:
guides/source/upgrading_ruby_on_rails.md
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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 then PostgreSQL visitor was [added](https://github.com/rails/rails/commit/6b7fdf3bf3675a14eae74acc5241089308153a34)
`add_column` was no longer receiving the column options directly. This
caused the options to be lost along the way.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
```
|
|/ |
|
| |
|
|
|
|
| |
since 9.1.
|
|
|
|
|
|
| |
Deprecate SchemaStatements#distinct, and make SchemaStatements#columns_for_distinct nodoc.
Conflicts:
activerecord/CHANGELOG.md
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Call assume_migrated_upto_version on connection to prevent it from first
being picked up in method_missing. In the base class, Migration,
method_missing expects the argument to be a table name, and calls
proper_table_name on the arguments before sending to connection. If
table_name_prefix or table_name_suffix is used, the schema version changes
to prefix_version_suffix, breaking `rake test:prepare`.
Fixes #10411.
|
| |
|
| |
|
| |
|
|\
| |
| |
| |
| |
| |
| | |
Confirm a record has not already been destroyed before decrementing counter cache
Conflicts:
activerecord/CHANGELOG.md
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
counter cache
At present, calling destroy multiple times on the same record results
in the belongs_to counter cache being decremented multiple times. With
this change the record is checked for whether it is already destroyed
prior to decrementing the counter cache.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Fixing CHANGLOG description
Remove extra line.
Remove blank lines.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
fixes #10419
Following code should raise IrreversibleMigration. But the code was
failing since options is an array and not a hash.
def change
change_table :users do |t|
t.remove_index [:name, :email]
end
end
Fix was to check if the options is a Hash before operating on it.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
assignment
For one-to-one nested associations, if you build the new (in-memory)
child object yourself before assignment, then the NestedAttributes
module will not overwrite it, e.g.:
class Member < ActiveRecord::Base
has_one :avatar
accepts_nested_attributes_for :avatar
def avatar
super || build_avatar(width: 200)
end
end
member = Member.new
member.avatar_attributes = {icon: 'sad'}
member.avatar.width # => 200
|
|\ \
| | |
| | | |
autosave_association issue that occurs when table has unique index (resubmission)
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
fixes bug introduced by #3329
These are the conditions necessary to reproduce the bug:
- For an association, autosave => true.
- An association record is being destroyed
- A new association record is being created.
- There is a unique index one of the association's fields.
- The record being created has the same value as the record being
destroyed on the indexed field.
Before, the deletion of records was postponed until after all
insertions/saves. Therefore the new record with the identical value in
the indexed field caused a non-unique value error to be thrown at the database
level.
With this fix, the deletions happen first, before the insertions/saves.
Therefore the record with the duplicate value is gone from the database
before the new record is created, thereby avoiding the non-uniuqe value
error.
|
|/ / |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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*
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
activerecord/lib/active_record/associations.rb states:
# [association=(associate)]
# Assigns the associate object, extracts the primary key, sets it as the foreign key,
# and saves the associate object.
Since commit 42dd5d9f2976677a4bf22347f2dde1a8135dfbb4 to fix #7191, this
is no longer the case if the associate has changed, but is the same
object. For example:
# Pirate has_one :ship
pirate = Pirate.create!(catchphrase: "A Pirate")
ship = pirate.build_ship(name: 'old name')
ship.save!
ship.name = 'new name'
pirate.ship = ship
That last line should trigger a save. Although we are not changing the
association, the associate (ship) has changed.
|
| |
|
| |
|