| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ActiveRecord associations automatically guess the inverse associations.
But this feature does not work correctly on assoctions for STI.
For example, before this commit
```
class Post < ActiveRecord::Base
belongs_to :author
end
class SpecialPost < Post; end
class Author < ActiveRecord::Base
has_many :posts
has_many :special_posts
end
```
`author.posts.first.author` works correctly, but
`author.special_posts.first.author` does not work correctly.
|
| |
|
|
|
|
|
|
|
|
| |
`SET time zone 'value'` is an alias for `SET timezone TO 'value'`.
https://www.postgresql.org/docs/current/static/sql-set.html
So if `variables["timezone"]` is specified, it is enough to
`SET timezone` once.
|
| |
|
|
|
|
|
| |
* Test `test_unabstracted_database_dependent_types` for `PostgreSQLAdapter`
* Add `test_change_column_with_new_precision_and_scale` for `SQLite3Adapter`
* This test case and comment was lost at 28bb02a78fd47527bb7a208d01a4594bb212812c
|
|
|
|
|
|
| |
Otherwise random CI failure will be caused.
https://travis-ci.org/rails/rails/jobs/265848046#L777
|
|
|
|
|
|
|
|
| |
(#29944)
Since 213796f, it was lost the ability that SQL with binds for `insert`,
`update`, and `delete` (like `select_all`). This restores the ability
because `insert`, `update`, and `delete` are public API, so it should
not be removed without deprecation.
|
|
|
|
|
|
|
| |
affected by scoping (#29997)
I tried to change the expectation in #29976, but it is expected behavior
at least for now. So I added the test cases to prevent anyone change the
expectation.
|
|
|
|
|
|
|
|
|
|
|
| |
`where.not` with multiple conditions is still unexpected behavior. But
`where.not` with only polymorphic association has already been fixed in
213796fb.
Closes #14161.
Closes #16983.
Closes #17010.
Closes #26207.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`TimestampsWithoutTransactionTest`
This commit addresses these failures when the backend RDBMS executes implicit commit for DDL like MySQL and Oracle.
```ruby
$ ARCONN=mysql2 bin/test test/cases/integration_test.rb test/cases/timestamp_test.rb --seed 58225 -n '/^(?:TimestampTest#(?:test_index_is_created_for_both_timestamps)|IntegrationTest#(?:test_cache_key_for_newer_updated_at|test_cache_key_format_for_existing_record_with_updated_at|test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format))$/' -v
Using mysql2
Run options: --seed 58225 -n "/^(?:TimestampTest#(?:test_index_is_created_for_both_timestamps)|IntegrationTest#(?:test_cache_key_for_newer_updated_at|test_cache_key_format_for_existing_record_with_updated_at|test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format))$/" -v
TimestampTest#test_index_is_created_for_both_timestamps = 0.19 s = .
IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at = 0.05 s = F
IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format = 0.02 s = F
IntegrationTest#test_cache_key_for_newer_updated_at = 0.01 s = F
Finished in 0.272880s, 14.6585 runs/s, 14.6585 assertions/s.
1) Failure:
IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:111]:
--- expected
+++ actual
@@ -1 +1 @@
-"developers/1-20170717135609430848"
+"developers/1-20170817135609283207"
2) Failure:
IntegrationTest#test_cache_key_format_for_existing_record_with_updated_at_and_custom_cache_timestamp_format [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:116]:
--- expected
+++ actual
@@ -1 +1 @@
-"cached_developers/1-20170717135609"
+"cached_developers/1-20170817135609"
3) Failure:
IntegrationTest#test_cache_key_for_newer_updated_at [/home/yahonda/git/rails/activerecord/test/cases/integration_test.rb:147]:
--- expected
+++ actual
@@ -1 +1 @@
-"developers/1-20170717145609430848"
+"developers/1-20170817135609283207"
4 runs, 4 assertions, 3 failures, 0 errors, 0 skips
$
```
`ActiveRecord::TestCase::TimestampTest#test_index_is_created_for_both_timestamps`
calls`ActiveRecord::TestCase::TimestampTest#setup` which updates `updated_at` column value.
```ruby
@developer = Developer.first
... snip ...
@developer.update_columns(updated_at: Time.now.prev_month)
```
This transaction expected to be rolled back, but if the backend RDBMS like MySQL perfomes
implicit commit when DDL executed, this transacion is committed by `create table` statement
inside `ActiveRecord::TestCase::TimestampTest#test_index_is_created_for_both_timestamps`.
It causes these failures above which expect `update_at` column value are not changed(rollbacked).
|
|\
| |
| | |
Allow `table_name_prefix` and `table_name_suffix` have `$`
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
MySQL 5.7 and PostgreSQL 9.6 allow table identifiers have the dollar sign.
* MySQL 5.7
https://dev.mysql.com/doc/refman/5.7/en/identifiers.html
> Permitted characters in unquoted identifiers:
> ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)
* PostgreSQL 9.6
https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html
> SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard.
Address #30044
[Yasuo Honda & Ryuta Kamizono]
|
|\ \
| | |
| | | |
Fix RuboCop offenses
|
| | |
| | |
| | |
| | | |
And enable `context_dependent` of Style/BracesAroundHashParameters cop.
|
|/ /
| |
| | |
Since c51f9b61 changed the "_before_type_cast" expectation for enum.
|
| |
| |
| |
| |
| |
| | |
Follow up of #29834.
Fixes #30266.
|
|\ \
| | |
| | |
| | | |
Ensure sum honors distinct on has_many through
|
| | |
| | |
| | |
| | |
| | |
| | | |
When using a has_many through relation and then summing an attribute
the distinct was not being used. This will ensure that when summing
an attribute, the number is only used once when distinct has been used.
|
|\ \ \
| | | |
| | | | |
Clarify base_class tests on abstract STI vs concrete STI
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Add `binary` helper method to fixtures.
|
| | |_|/
| |/| | |
|
|\ \ \ \
| | | | |
| | | | | |
Fix `reflection.association_primary_key` for `has_many` association
|
| | |/ /
| |/| |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
It is incorrect to treat `options[:primary_key]` as
`association_primary_key` if `has_many` associations because the
`:primary_key` means the column on the owner record, not on the
association record. It will break `ids_reader` and `ids_writer`.
```ruby
people(:david).essay_ids
# => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David'
```
Fixes #14439.
|
|\ \ \ \
| | | | |
| | | | | |
Allow `serialize` with a custom coder on `json` and `array` columns
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
We already have a test case for `serialize` with a custom coder in
`PostgresqlHstoreTest`.
https://github.com/rails/rails/blob/v5.1.3/activerecord/test/cases/adapters/postgresql/hstore_test.rb#L316-L335
|
|\ \ \ \ \
| |_|_|_|/
|/| | | | |
Check :scope input in Uniqueness validator
|
| | |/ /
| |/| | |
|
| |/ /
|/| |
| | |
| | |
| | |
| | |
| | |
| | | |
`Firm.id` is a bigint if mysql2 adapter is used, but `firm_id` is an
integer. It will cause an out of range error.
https://travis-ci.org/rails/rails/jobs/264112814#L776
https://travis-ci.org/rails/rails/jobs/264112835#L919
|
|\ \ \
| | | |
| | | | |
Fix random CI failure due to non-deterministic sorting order
|
| |/ /
| | |
| | |
| | | |
https://travis-ci.org/rails/rails/jobs/263617099#L769-L775
|
|\ \ \
| |/ /
|/| |
| | |
| | | |
kamipo/move_test_not_compatible_with_serialize_macro
Move `test_not_compatible_with_serialize_macro` to `JSONSharedTestCases`
|
| | |
| | |
| | |
| | | |
Because `JSONSharedTestCases` is also used for `Mysql2JSONTest`.
|
|\ \ \
| | | |
| | | |
| | | |
| | | | |
chopraanmol1/support_for_has_many_and_has_one_for_where_relation
Fixed query building when relation is passed for has one or has many association in where
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
has many association wrong set of primary key and foreign key are selected.
Changed code to use 'join' primary key and foreign key over 'association' primary key and foreign key.
|
|\ \ \ \
| | | | |
| | | | | |
Add `:authors` to address random failures at HasOneAssociationsTest
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
* sqlite3 - 2 failures
```ruby
$ ARCONN=sqlite3 bin/test test/cases/associations/has_one_associations_test.rb test/cases/view_test.rb --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose
Using sqlite3
Run options: --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose
ViewWithoutPrimaryKeyTest#test_attributes = 0.02 s = .
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace = 0.12 s = F
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy = 0.01 s = F
Finished in 0.162504s, 18.4610 runs/s, 18.4610 assertions/s.
1) Failure:
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace [/home/yahonda/git/rails/activerecord/test/cases/associations/has_one_associations_test.rb:725]:
Expected true to be nil or false
2) Failure:
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy [/home/yahonda/git/rails/activerecord/test/cases/associations/has_one_associations_test.rb:715]:
Expected true to be nil or false
3 runs, 3 assertions, 2 failures, 0 errors, 0 skips
```
* mysql2 - 1 failure
```
$ ARCONN=mysql2 bin/test test/cases/associations/has_one_associations_test.rb test/cases/view_test.rb --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose
Using mysql2
Run options: --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose
ViewWithoutPrimaryKeyTest#test_attributes = 0.07 s = .
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace = 0.27 s = F
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy = 0.02 s = .
Finished in 0.362779s, 8.2695 runs/s, 8.2695 assertions/s.
1) Failure:
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace [/home/yahonda/git/rails/activerecord/test/cases/associations/has_one_associations_test.rb:725]:
Expected true to be nil or false
3 runs, 3 assertions, 1 failures, 0 errors, 0 skips
```
* postgresql - 0 failures
```ruby
$ ARCONN=postgresql bin/test test/cases/associations/has_one_associations_test.rb test/cases/view_test.rb --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose
Using postgresql
Run options: --seed 48032 -n "/^(?:ViewWithoutPrimaryKeyTest#(?:test_attributes)|HasOneAssociationsTest#(?:test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy|test_destroyed_by_association_set_in_child_destroy_callback_on_replace))$/" --verbose
ViewWithoutPrimaryKeyTest#test_attributes = 0.06 s = .
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_parent_destroy = 0.22 s = .
HasOneAssociationsTest#test_destroyed_by_association_set_in_child_destroy_callback_on_replace = 0.02 s = .
Finished in 0.311217s, 9.6396 runs/s, 9.6396 assertions/s.
3 runs, 3 assertions, 0 failures, 0 errors, 0 skips
```
|
|\ \ \ \
| |_|/ /
|/| | | |
Return Not found Ids in ActiveRecord::NotFound
|
| | | |
| | | |
| | | |
| | | |
| | | | |
This builds on top of 15e2da656f41af0124f7577858536f3b65462ad5.
now it also returns exact Ids which were not found which will be debugging simple.
|
|\ \ \ \
| | | | |
| | | | | |
Fix random CI failure due to non-deterministic sorting order
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
```
rails/activerecord$ bundle exec rake postgresql:test --verbose TESTOPTS="--seed=36062"
Failure:
AssociationsJoinModelTest#test_has_many_through_polymorphic_has_one
[/home/travis/build/rails/rails/activerecord/test/cases/associations/join_model_test.rb:407]:
--- expected
+++ actual
@@ -1 +1 @@
-[
#<Tagging id: 1, tag_id: 1, super_tag_id: 2, taggable_type: "Post", taggable_id: 1, comment: nil>,
#<Tagging id: 2, tag_id: 1, super_tag_id: nil, taggable_type: "Post", taggable_id: 2, comment: nil>
]
+#<ActiveRecord::Associations::CollectionProxy [
#<Tagging id: 2, tag_id: 1, super_tag_id: nil, taggable_type: "Post", taggable_id: 2, comment: nil>,
#<Tagging id: 1, tag_id: 1, super_tag_id: 2, taggable_type: "Post", taggable_id: 1, comment: nil>
]>
```
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
```
rails/activerecord$ bundle exec rake postgresql:test TESTOPTS="--seed=26536"
..(compressed)....F
Failure:
DirtyTest#test_save_should_not_save_serialized_attribute_with_partial_writes_if_not_present [/home/travis/build/rails/rails/activerecord/test/cases/dirty_test.rb:473]:
Expected nil to not be nil.
```
|
| |/ /
|/| |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
It should be sorted to be deterministic executed result.
```
% bundle exec rake test_postgresql --verbose TESTOPTS="--seed=52812"
(snip)
Failure:
HasManyThroughAssociationsTest#test_has_many_association_through_a_has_many_association_to_self [/Users/kamipo/src/github.com/rails/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb:820]:
--- expected
+++ actual
@@ -1 +1 @@
-[#<Person id: 85, primary_contact_id: 84, gender: "M", number1_fan_id: 1, lock_version: 0, comments: nil, followers_count: 0, friends_too_count: 0, best_friend_id: nil, best_friend_of_id: nil, insures: 0, born_at: nil, created_at: "2017-08-08 07:33:52", updated_at: "2017-08-08 07:33:52", first_name: "John">, #<Person id: 1, primary_contact_id: 2, gender: "M", number1_fan_id: 3, lock_version: 0, comments: nil, followers_count: 1, friends_too_count: 1, best_friend_id: nil, best_friend_of_id: nil, insures: 0, born_at: nil, created_at: "2017-08-08 07:33:49", updated_at: "2017-08-08 07:33:49", first_name: "Michael">, #<Person id: 3, primary_contact_id: 2, gender: "F", number1_fan_id: 1, lock_version: 0, comments: nil, followers_count: 1, friends_too_count: 1, best_friend_id: nil, best_friend_of_id: nil, insures: 0, born_at: nil, created_at: "2017-08-08 07:33:49", updated_at: "2017-08-08 07:33:49", first_name: "Susan">]
+#<ActiveRecord::Associations::CollectionProxy [#<Person id: 1, primary_contact_id: 2, gender: "M", number1_fan_id: 3, lock_version: 0, comments: nil, followers_count: 1, friends_too_count: 1, best_friend_id: nil, best_friend_of_id: nil, insures: 0, born_at: nil, created_at: "2017-08-08 07:33:49", updated_at: "2017-08-08 07:33:49", first_name: "Michael">, #<Person id: 3, primary_contact_id: 2, gender: "F", number1_fan_id: 1, lock_version: 0, comments: nil, followers_count: 1, friends_too_count: 1, best_friend_id: nil, best_friend_of_id: nil, insures: 0, born_at: nil, created_at: "2017-08-08 07:33:49", updated_at: "2017-08-08 07:33:49", first_name: "Susan">, #<Person id: 85, primary_contact_id: 84, gender: "M", number1_fan_id: 1, lock_version: 0, comments: nil, followers_count: 0, friends_too_count: 0, best_friend_id: nil, best_friend_of_id: nil, insures: 0, born_at: nil, created_at: "2017-08-08 07:33:52", updated_at: "2017-08-08 07:33:52", first_name: "John">]>
```
|
|\ \ \
| |_|/
|/| | |
Do not let use `serialize` on native JSON/array column
|
| |/ |
|
| |
| |
| |
| |
| |
| | |
Actually `StatementCache#execute` is always passed the same klass that
the owner klass of the connection when the statement cache is created.
So passing `klass` to `StatementCache.new` will make more DRY.
|
|\ \
| | |
| | |
| | |
| | | |
kamipo/relation_merger_should_not_fill_empty_values
`Relation::Merger` should not fill `values` with empty values
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Currently `Relation#merge` will almost fill `values` with empty values
(e.g. `other.order_values` is always true, it should be
`other.order_values.any?`). This means that `Relation#merge` always
changes `values` even if actually `values` is nothing changed. This
behavior will makes `Relation#empty_scope?` fragile. So `Relation#merge`
should avoid unnecessary changes.
|
|\ \ \
| | | |
| | | | |
Fix `find_by` with range conditions
|
| | | |
| | | |
| | | |
| | | |
| | | | |
`StatementCache` doesn't support range conditions. So we need to through
the args to `FinderMethods#find_by` if range value is passed.
|