| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
[#20473]
|
| |
|
|
|
|
|
|
|
|
| |
When passing an instance of `ActiveRecord::Base` to `#update`, it would
internally call `#find`, resulting in a misleading deprecation warning.
This change gives this deprecated use of `#update` its own, meaningful
warning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Dirty checking keeps a hash where the keys are the column name and the
value is a dup of the value from the database[1]. This hash is kept for
every AR object, which means that we dup every column name for every AR
object that does dirty checking. Freezing the column name prevents the
column name from being duped and reduced overall string allocations.
Here is a benchmark to demonstrate:
```ruby
require 'active_record'
class Topic < ActiveRecord::Base
end
20.times do |i|
Process.waitpid fork {
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Base.connection.instance_eval do
create_table(:topics) do |t|
t.string :title, limit: 250
t.string :author_name
t.string :author_email_address
t.string :parent_title
t.string :type
t.string :group
i.times do |j|
t.string :"aaa#{j}"
end
t.timestamps null: true
end
end
ObjectSpace::AllocationTracer.setup(%i{type})
Topic.create title: "aaron" # heat cache
result = ObjectSpace::AllocationTracer.trace do
10.times do |i|
Topic.create title: "aaron #{i}"
end
end
puts "#{Topic.columns.length},#{(result.find { |k,v| k.first == :T_STRING }.last.first / 10)}"
}
end
```
1. https://github.com/rails/rails/blob/3ad381c3f8598d9920998c8949a96b5f62b280dd/activerecord/lib/active_record/attribute_set/builder.rb#L102
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The focus of this change is to make the API more accessible.
References to method and classes should be linked to make it easy to
navigate around.
This patch makes exzessiv use of `rdoc-ref:` to provide more readable
docs. This makes it possible to document `ActiveRecord::Base#save` even
though the method is within a separate module
`ActiveRecord::Persistence`. The goal here is to bring the API closer to
the actual code that you would write.
This commit only deals with Active Record. The other gems will be
updated accordingly but in different commits. The pass through Active
Record is not completely finished yet. A follow up commit will change
the spots I haven't yet had the time to update.
/cc @fxn
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
Documentation ActiveRecord Attributes API code fix
|
| |
| |
| |
| |
| |
| |
| | |
I came across this while trying it out, with the provided code the
`MoneyType` does not save as it complains that `Fixnum` does not
define `include?`. I think the sensible thing is to check if it
already is a `Numeric`.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The rdoc parser seems to trip on the `private def` construct.
Public methods following a method defined with `private def` are not
visible inside the module docs but are appended to the top-most module.
For example the method `ActiveRecord::QueryMethods#distinct` was listed
under `ActiveRecord#distinct`.
/cc @sgrif
|
| |
| |
| |
| | |
[ci skip]
|
| |
| |
| |
| |
| |
| | |
This class is only used internally. We should keep it out of public
documentation. This patch adds nodoc for
`ActiveRecord::Associations::Builder` and everything nested within.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This error is raised in certain situations when eager loading
polymorphic associations. We even mention it in our docs. It should be
included in our API.
Conflicts:
activerecord/lib/active_record/associations.rb
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Also unify the format of code example output. Only use `# =>` if the
actual return value is described. Otherwise simply use `#`.
Conflicts:
activerecord/lib/active_record/relation/query_methods.rb
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Closes #21563.
The `name` argument of `add_references` was both used to generate the
column name `<name>_id` and as the target table for the foreign key
`name.pluralize`.
It's primary purpose is to define the column name. In cases where the
`to_table` of the foreign key is different than the column name we
should be able to specify it individually.
|
| |
| |
| |
| |
| | |
Current master branch includes many schema dumping improvements.
It extract these features to the appropriate files.
|
|\ \
| | |
| | |
| | | |
Remove deprecated pg_dump -i flag
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
Current master branch includes many schema creation improvements in
MySQL. It extract these features to the appropriate file.
|
|/ /
| |
| |
| |
| | |
Current master branch includes many schema definition improvements in
MySQL. It extract these features to the appropriate file.
|
|\ \
| | |
| | |
| | | |
Make AR#increment! and #decrement! concurrency-safe
|
| | | |
|
|\ \ \
| | | |
| | | | |
Modify the scope method documentation
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Adds a paragraph to the documentation of the `ActiveRecord::Scoping::Named.scope` method,
explaining that the method is intended to return an ActiveRecord::Relation object to be
composable with other scopes.
In the case that in the case that `nil` or `false` are returned, the method returns
an `all` relation instead.
This unexpected behaviour is mentioned in #19249 #14256 #21465 and #21882 and wasn't
documented at all. This commit adds this documentation.
|
| | | |
| | | |
| | | |
| | | | |
`require 'active_support/core_ext/string/filters'` was added in b3bfa36. However, it is no longer needed from 3ae981814.
|
|/ / /
| | |
| | |
| | |
| | |
| | | |
`pk_and_sequence_for` is implemented for PG and MySQL adapters (not
implemented for Sqlite3 adapter). But MySQL adapters are not using
`pk_and_sequence_for` already.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Any gems or libraries which do work with serialization or YAML will
ultimately need to compare these objects (albeit indirectly) to ensure
correctness. These will likely never get used internally (as they're
slow), but we should still expose them for others.
|
| | | |
|
|\ \ \
| | | |
| | | | |
No need to declare ActiveRecord::Attributes::Type
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Skip _select! call unless needed for preloader
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
the default scope will select all fields. removing this
improves performance and reduces String creation.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Docs: Update options for add_reference
|
| | | | | |
| | | | | |
| | | | | | |
[ci skip]
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
* before
```
people = Person.where(group: 'expert')
people.update(group: 'masters')
Note: Updating a large number of records will run a
UPDATE query for each record, which may cause a performance
issue. So if it is not needed to run callbacks for each update, it is
preferred to use <tt>update_all</tt> for updating all records using
a single query.
```
* after
```
people = Person.where(group: 'expert')
people.update(group: 'masters')
```
Note: Updating a large number of records will run an
UPDATE query for each record, which may cause a performance
issue. So if it is not needed to run callbacks for each update, it is
preferred to use <tt>update_all</tt> for updating all records using
a single query.
|
|\ \ \ \ \ \ |
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
`alias :migrations_path= :migrations_paths=`, so
`migrations_path = some_string` is correct.
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
documentations [ci skip]
|
|\ \ \ \ \ \ \
| | | | | | | |
| | | | | | | | |
Wrong usage of 'a' in docs fixed [ci skip]
|
| | | | | | | | |
|
|/ / / / / / /
| | | | | | |
| | | | | | |
| | | | | | | |
to reduce allocation of same object
|