| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Benchmark:
```ruby
require 'objspace'
require 'active_record'
ActiveRecord::Base.establish_connection adapter: "sqlite3",
database: ":memory:"
ActiveRecord::Base.connection.instance_eval do
create_table(:articles) { |t| t.string :name }
end
class Article < ActiveRecord::Base; end
a = Article.create name: "foo"
a = Article.find a.id
N = 10
ObjectSpace::AllocationTracer.trace do
N.times { Article.find a.id }
end
ObjectSpace::AllocationTracer.allocated_count_table
table.sort_by { |_,x| x }.each do |k,v|
p k => (v / N)
end
```
|
| |
|
|
|
|
|
|
|
| |
Honoring an overidden `rack.test` allows testing closed connection between
multiple requests. This is useful if you're working on database resiliency, to
ensure the connection is in the expected state from one request to another on
the same worker.
|
|
|
|
|
|
| |
it doesn't work on SQLite3 since it doesn't support truncate, but that's
OK. If you call truncate on the connection, you're now bound to that
database (same as if you use hstore or any other db specific feature).
|
|
|
|
|
|
|
| |
Previously the documentation stated that `primary_key` should be the name of
a *method* that returns the primary key used for the association. This is
incorrect. This changes the documentation to say that the value must be the
name of a column.
|
|
|
|
| |
:foreign_key option that's a symbol
|
|
|
|
|
| |
The hash is now string-keyed, and [_]reflect_on_association calls `to_s` on the
argument anyway.
|
|
|
|
|
|
|
|
|
| |
For now, we will just skip the cache when a non-column key is used in the hash.
If the future, we can probably move some of the logic in PredicateBuilder.expand
up the chain to make caching possible for association queries.
Closes #16903
Fixes #16884
|
|
|
|
|
|
| |
This is pretty lame though, so feel free to send a PR with a better fix! ;)
cc @zev @tenderlove
|
|\
| |
| | |
Update RecordNotFound exception cases to include a message with the
|
| |
| |
| |
| | |
Model that the Record was not found in.
|
| |
| |
| |
| |
| |
| | |
- Added a note about some features which are not dependent on
auto-generated ID's.
- [ci skip]
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
While investigating #16951 I found that another library's monkey-patching of
`Enumerable` was causing the test migrations helper to break when trying to
build the `CREATE DATABASE` statement. The prior approach used `#sum` to build
the string from the options hash.
As the code that combines the options to build the database statement is not
user-facing, using `#inject` here instead will remove the only place where the
database creation/migration code is dependent on ActiveSupport's monkey-patching
of `Enumerable`.
|
| | |
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | | |
Don't autosave unchanged has_one through records
Conflicts:
activerecord/CHANGELOG.md
|
| | | |
|
|\ \ \
| | | |
| | | | |
Allow YAML serialization when using TZ aware attributes
|
| | | | |
|
|\ \ \ \
| |/ / /
|/| | |
| | | |
| | | | |
kongregate/fix-activerecord-deprecated_finders-find-symbol
ActiveRecord deprecated finders are broken in 4.2
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | | |
Maintain compatibility for:
* ActiveRecord::Base#find(:all)
* ActiveRecord::Base#find(:first)
* ActiveRecord::Base#find(:last)
|
| | | |
|
|/ /
| |
| |
| |
| |
| | |
Closes #16907.
[Matthew Draper & Yves Senn]
|
|\ \
| | |
| | |
| | | |
Data corruption risk: Roll back open transactions when the running thread is killed.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Improved the error messaging for the DangerousAttributeError exception
|
| | | |
| | | |
| | | |
| | | | |
that the conflict could be because of a conflicting attribute.
|
|/ / /
| | |
| | |
| | |
| | |
| | | |
[Matthew Draper & Yves Senn]
Closes #16860. (pull request to discuss the implementation)
|
| | |
| | |
| | |
| | |
| | |
| | | |
Allows :limit defaults to be changed without pulling the rug out from
under old migrations that omitted :limit because it matched the default
at the time.
|
| | | |
|
| | | |
|
|\ \ \
| | | |
| | | | |
Updating Associations::Preloader docs
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Much of the previous documentation introduced features new in 2011. This
commit refreshes it to provide clearer code examples and spends more
time describing the normal case (preloaded associations) and less time
describing the fallback.
[ci skip]
|
|\ \ \ \
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
SQLite3Adapter now checks for views in table_exists? fixes: 14041
Conflicts:
activerecord/CHANGELOG.md
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
`AbstractAdapter#supports_views?` defaults to `false` so we have to turn it on
in adapter subclasses. Currently the flag only controls test execution.
/cc @yahonda
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Closes #16684.
This is achieved by always generating `GeneratedAssociationMethods` when
`ActiveRecord::Base` is subclassed. When some of the included modules
of `ActiveRecord::Base` were reordered this behavior was broken as
`Core#initialize_generated_modules` was no longer called. Meaning that
the module was generated on first access.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Fix query with nested array in Active Record
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
`User.where(id: [[1,2],3])` was equal to `User.where(id:[1, 2, 3])`
in Rails 4.1.x but because of some refactoring in Arel this stopped
working in 4.2.0. This fixes it in Rails.
[Dan Olson & Cristian Bica]
|
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
exclusively
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
* Add private method primary_key_for, which more clearly shows that the
expected return value is nil when a primary key is not found.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
* Consistent whitespace
* Remove unnecessary parentheses
|
|/ / / / / |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Callback order in Active Record objects are important. Users should not
define callbacks before the association definition or surprising
behaviours like the described at #3798 will happen. This callback order
dependency is documented at https://github.com/rails/rails/blob/31bfcdc77ca0d8cec9b5fe513bdc6f05814dd4f1/activerecord/lib/active_record/associations.rb#L1222-1227.
This reverts #15728.
Fixes #16620.
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This is cased by 03118bc + 9b5d603. The first commit referenced the undefined
local variable `column` when it should be using `reflection.type` as the lookup
key. The second commit changed `build_arel` to not modify the `bind_values` in-
place so we need to combine the arel's `bind_values` with the relation's when
building the SQL.
Fixes #16591
Related #15821 / #15892 / 7aeca50
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Skip StatementCache for eager loaded associations
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Eagerly loaded collection and singular associations are ignored by the StatementCache, which causes errors when the queries they generate reference columns that were not eagerly loaded.
This commit skips the creation of the StatementCache as a fix for these scenarios.
|
|/ / / / / |
|
|\ \ \ \ \
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
eileencodes/refactor-scope_chain-on-through-refelction-to-eliminate-branch-in-eval_scope
Always add lambda to scope chain to eliminate branch in eval_scope
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
We convert all other scopes to lambda's so it makes sense that we should
always returns a lambda on a ThroughReflection as well. This eliminates
the need to check if the scope is a Relation.
|