Akira Matsuda
9d4f79d3d3
[Active Record] require => require_relative
2017-07-01 18:38:04 +09:00
fatkodima
89d56699bd
Delete stale comment for `AR::Associations::Builder::CollectionAssociation`
2017-07-01 00:50:12 +03:00
Rafael França
9c2ad53bef
Merge pull request #29623 from kamipo/should_use_same_connection_in_query_cache
...
Should use the same connection in using query cache
2017-06-29 12:02:55 -04:00
Ryuta Kamizono
1d264f0bcd
Fix the next version of Rails from 5.3 to 6.0
2017-06-29 23:33:11 +09:00
Ryuta Kamizono
d9fca84d21
Deprecate delegating to `arel` in `Relation`
...
Active Record doesn't rely delegating to `arel` in the internal since
425f2ca
. The delegation is a lower priority than delegating to `klass`,
so it is pretty unclear which method is delegated to `arel`.
For example, `bind_values` method was removed at b06f64c
(a series of
changes 79f71d3...b06f64c
). But a
relation still could respond to the method because `arel` also have the
same named method (#28976 ).
Removing the delegation will achieve predictable behavior.
2017-06-29 23:09:05 +09:00
Rafael França
4448873c87
Merge pull request #29616 from kamipo/remove_unused_aliased_table_name
...
Remove unused `aliased_table_name` in `Association`
2017-06-29 08:25:45 -04:00
Rafael França
ae751b8f6c
Merge pull request #29569 from kamipo/fix_to_scoping_is_correctly_restored
...
Fix to scoping is correctly restored
2017-06-29 08:24:58 -04:00
Ryuta Kamizono
abbc8351cd
Should use the same connection in using query cache
...
`test_cache_is_available_when_using_a_not_connected_connection` is
always failed if running only the test since #29609 .
```
% ARCONN=mysql2 be ruby -w -Itest test/cases/query_cache_test.rb -n test_cache_is_available_when_using_a_not_connected_connection
Using mysql2
Run options: -n test_cache_is_available_when_using_a_not_connected_connection --seed 15043
F
Finished in 0.070519s, 14.1806 runs/s, 28.3612 assertions/s.
1) Failure:
QueryCacheTest#test_cache_is_available_when_using_a_not_connected_connection [test/cases/query_cache_test.rb:336]:
2 instead of 1 queries were executed.
Queries:
SELECT `tasks`.* FROM `tasks` WHERE `tasks`.`id` = ? LIMIT ?
SET NAMES utf8 COLLATE utf8_unicode_ci, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483.
Expected: 1
Actual: 2
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips
```
This failure is due to `LogSubscriber` will use not connected
`ActiveRecord::Base.connection` even if `Task.connection` is connected.
I fixed to always pass `type_casted_binds` to log subscriber to avoid
the issue.
2017-06-29 16:37:45 +09:00
Rafael França
1e798ccb8f
Merge pull request #28932 from kamipo/remove_method_missing_in_relation_delegation
...
Remove `method_missing` in `Relation::Delegation`
2017-06-28 17:40:03 -04:00
Rafael França
9c49b334f9
Merge pull request #29612 from kamipo/use_quote_method_rather_than_single_quote
...
Use `quote` method rather than single quotes to identifiers in SQL
2017-06-28 17:36:39 -04:00
Rafael França
3c101453cb
Merge pull request #29129 from kamipo/prevent_extra_through_scope
...
Prevent extra `through_scope`
2017-06-28 17:36:13 -04:00
Ryuta Kamizono
99912ed926
Fix to scoping is correctly restored
...
This regression was caused by #23004 .
If STI subclass is using scoping in parent class scoping,
`current_scope` in subclass is never restored.
I fixed to restore `current_scope` to previous value correctly.
2017-06-29 06:35:10 +09:00
Rafael França
65b02ea560
Merge pull request #29301 from kamipo/receiver_in_scope_should_be_relation
...
The receiver in a scope should be a `relation`
2017-06-28 17:28:14 -04:00
Rafael França
7f58b7dd49
Merge pull request #29416 from kamipo/remove_unused_subject_model
...
Remove unused `Subject` model in tests
2017-06-28 17:25:13 -04:00
Rafael França
f1a6b52a4d
Merge pull request #29076 from kamipo/use_timestamp_attributes_for_update_in_model
...
Use `timestamp_attributes_for_update_in_model` rather than `timestamp_attributes_for_update`
2017-06-28 17:18:48 -04:00
Rafael França
b04082100f
Merge pull request #28928 from kamipo/remove_habtm_initialize
...
Remove `HasAndBelongsToManyReflection#initialize`
2017-06-28 17:18:03 -04:00
Ryuta Kamizono
4aa4a449e0
Remove unused `aliased_table_name` in `Association`
...
`aliased_table_name` in `Association` was added at a3502c4
.
`aliased_table_name` in `JoinDependency` (added at 55854c4
) is used, but
it looks like that added one in `Association` is never used from the
beginning.
2017-06-29 06:00:17 +09:00
Rafael França
8c65abe5f8
Merge pull request #29405 from kamipo/locked_should_not_build_arel
...
`Relation#locked?` should not build arel
2017-06-28 16:43:28 -04:00
Rafael França
97d276bf8a
Merge pull request #29614 from kamipo/show_query_cache_keys_2
...
Show query cache keys in `test_middleware_caches`
2017-06-28 15:55:01 -04:00
Ryuta Kamizono
ede8da4b26
Use `quote` method rather than single quotes to identifiers in SQL
...
Because identifiers in SQL could include a single quote.
Related #24950 , #26784 .
2017-06-29 04:17:15 +09:00
Rafael Mendonça França
316e3c2ff1
Merge pull request #29601 from kamipo/fix_eager_loading_to_respect_store_full_sti_class
...
Fix eager loading to respect `store_full_sti_class` setting
2017-06-28 14:42:55 -04:00
Rafael França
33de72667a
Merge pull request #29610 from kamipo/dont_passing_klass_connection_to_association_scope
...
Don't passing `klass.connection` to `AssociationScope`
2017-06-28 14:41:59 -04:00
Rafael França
f94b2e8503
Merge pull request #29611 from kamipo/add_test_case_for_unscoping_default_scope
...
Add a test case for unscoping `default_scope` in associations
2017-06-28 14:32:51 -04:00
Ryuta Kamizono
425f2cacaf
Remove delegating to arel in a relation
...
The delegation was needed since passing `relation` with
`relation.bound_attributes`. It should use `relation.arel` in that case.
2017-06-29 03:27:45 +09:00
Rafael França
8adef0b833
Merge pull request #29609 from tsukasaoishi/query_cache_from_beginning
...
Enable query cache if set a configurations
2017-06-28 14:26:57 -04:00
Ryuta Kamizono
4cf41833ed
Show query cache keys in `test_middleware_caches`
...
`test_middleware_caches` also failed same as #29600 .
https://travis-ci.org/rails/rails/jobs/248017174#L487-L489
2017-06-29 03:15:02 +09:00
Ryuta Kamizono
b084fe9054
Fix eager loading to respect `store_full_sti_class` setting
2017-06-29 01:40:01 +09:00
Rafael França
2f36c9889a
Merge pull request #29604 from kamipo/fix_ids_reader_to_respect_case_sensitive_pk
...
Fix `ids_reader` to respect case sensitive primary key
2017-06-28 12:36:42 -04:00
Tsukasa OISHI
1b4360dea8
Enable query cache if set a configurations
...
ActiveRecord query cache is available when a connection is connected.
Therefore, query cache is unavailable when entering the ActiveRecord::Base.cache block without being connected.
```ruby
ActiveRecord::Base.cache do
Task.find(1) # access to database.
Task.find(1) # access to database. unavailable query cache
end
```
If we use query cache with batch script etc, we need to connect before that.
```ruby
Task.connection
ActiveRecord::Base.cache do
Task.find(1) # access to database.
Task.find(1) # available query cache
end
```
Before version 3.1, query cache had been enabled if a configuration was set up.
In order to solve the `DATABASE_URL` issue(#8074 ), ActiveRecord has checked whether a connection is connected or not.
Today, ActiveRecord.configurations respect `DATABASE_URL`.
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/core.rb#L46
2017-06-29 01:34:48 +09:00
Ryuta Kamizono
eacec5defe
Don't passing `klass.connection` to `AssociationScope`
...
Passing `klass.connection` is redundant because `AssociationScope` is
passed an association itself and an association has `klass`.
2017-06-29 01:26:18 +09:00
Rafael França
5241b26512
Merge pull request #29602 from kamipo/use_reload_in_test_find_first_after_reload
...
Use `reload` in `test_find_first_after_reload`
2017-06-28 12:21:25 -04:00
Ryuta Kamizono
daec73aa42
Add a test case for unscoping `default_scope` in associations
...
Unscoping `default_scope` in associations has already supported (#17360
for preloading, c9cf8b8
for eager loading).
Fixes #20679 .
Closes #16531 .
2017-06-29 01:19:04 +09:00
Rafael França
bf7606d4eb
Merge pull request #29600 from kamipo/show_query_cache_keys
...
Show query cache keys in `test_exceptional_middleware_clears_and_disables_cache_on_error`
2017-06-28 12:05:54 -04:00
Rafael França
cf8c46938b
Merge pull request #29588 from greysteil/add-gemspec-links
...
Add source code and changelog links to gemspecs
2017-06-28 11:24:02 -04:00
Ryuta Kamizono
bf3f201000
Fix `ids_reader` to respect case sensitive primary key
...
```ruby
car = Car.create!(name: "Tofaş")
# Before
car.bulb_ids # => SELECT "bulbs".ID FROM "bulbs" WHERE "bulbs"."name" = $1 AND "bulbs"."car_id" = $2 [["name", "defaulty"], ["car_id", 3]]
# After
car.bulb_ids # => SELECT "bulbs"."ID" FROM "bulbs" WHERE "bulbs"."name" = $1 AND "bulbs"."car_id" = $2 [["name", "defaulty"], ["car_id", 3]]
```
2017-06-28 21:59:28 +09:00
Eileen M. Uchitelle
f138ffab13
Merge pull request #29593 from kratob/master
...
ActiveRecord: do not create "has many through" records that have been removed
2017-06-28 08:20:57 -04:00
Ryuta Kamizono
e614be2d80
Use `reload` in `test_find_first_after_reload`
...
And use `assert_same` instead of `assert_equal` and tiny fix assert
message s/#reload/#reset/.
Follow up of #29511 .
2017-06-28 21:19:08 +09:00
Tobias Kraze
c41247a3d2
ActiveRecord: do not create "has many through" records that have been removed
...
If a record was built on a HasManyThroughAssociation, then removed, and
then the record was saved, the removed record would be created anyways.
2017-06-28 14:18:48 +02:00
Grey Baker
3e6ce1cd69
Add source code and changelog links to gemspecs
2017-06-28 10:06:01 +01:00
Ryuta Kamizono
e2d8f1844d
Show query cache keys in `test_exceptional_middleware_clears_and_disables_cache_on_error`
...
`test_exceptional_middleware_clears_and_disables_cache_on_error` in
postgresql adapter sometime fails recently. Show the query cache keys to
investigte the cause.
https://travis-ci.org/rails/rails/jobs/246467252#L490-L493
2017-06-28 17:30:10 +09:00
Rafael França
7f9986237f
Merge pull request #29556 from kamipo/extract_ordered_relation
...
Extract `ordered_relation` in `FinderMethods`
2017-06-27 14:29:35 -04:00
Rafael França
faa225fd02
Merge pull request #29589 from kamipo/refactor_join_scope
...
Refactor join dependency to move building constraints to `join_scope` in `Reflection`
2017-06-27 13:31:13 -04:00
Ryuta Kamizono
442c15f141
Move building constraint to `join_scope` in `Reflection`
2017-06-27 20:32:17 +09:00
Ryuta Kamizono
23bcc6578e
Move constructing polymorphic type to `join_scope` in `Reflection`
2017-06-27 18:47:42 +09:00
Ryuta Kamizono
0496b7b3b2
Skip instantiating `NullPreloader` if `assoc.klass` is nil
...
Simply we can skip instantiating `NullPreloader` if `assoc.klass` is
nil.
2017-06-27 18:27:56 +09:00
Rafael França
61cc630ac7
Merge pull request #29571 from kamipo/fix_extracting_references_via_order_values
...
Fix extracting `references` via `order_values` to respect quoting
2017-06-26 17:25:45 -04:00
Rafael França
7b841b61f5
Merge pull request #29557 from kamipo/extract_build_scope_and_predicate_builder
...
Extract `build_scope` and `predicate_builder` in `Reflection`
2017-06-26 17:25:18 -04:00
Rafael França
f3a64adb4e
Merge pull request #29568 from kamipo/ensure_using_correct_alias_tracker
...
Ensure that using correct alias tracker
2017-06-26 17:18:36 -04:00
Rafael França
36d3f59a31
Merge pull request #29511 from jhawthorn/clear_offsets_cache_on_collection_proxy
...
Rails 5.1.2.rc1 regression - Clear offset cache on CollectionProxy reset/reload
2017-06-26 14:50:34 -04:00
Rafael França
229d8b2a7e
Merge pull request #29519 from Edouard-chin/ec-structure-flags-order
...
Pass `structure_dump_flags` / `structure_load_flags` options before any other:
2017-06-26 13:44:22 -04:00