| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Follow up of #31004.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This pull request addresses these 17 failures when tested with Oracle enhanced adapter.
All of these failures are due to the incorrect number of queries. Here is the first one.
```ruby
$ ARCONN=oracle bin/test test/cases/nested_attributes_test.rb:1086
Using oracle
Run options: --seed 27985
F
Finished in 0.874514s, 1.1435 runs/s, 1.1435 assertions/s.
1) Failure:
TestHasManyAutosaveAssociationWhichItselfHasAutosaveAssociations#test_circular_references_do_not_perform_unnecessary_queries [/home/yahonda/git/rails/activerecord/test/cases/nested_attributes_test.rb:1086]:
6 instead of 3 queries were executed.
Queries:
select us.sequence_name from all_sequences us where us.sequence_owner = :owner and us.sequence_name = :sequence_name
INSERT INTO "SHIPS" ("NAME", "ID") VALUES (:a1, :a2)
select us.sequence_name from all_sequences us where us.sequence_owner = :owner and us.sequence_name = :sequence_name
INSERT INTO "SHIP_PARTS" ("NAME", "SHIP_ID", "UPDATED_AT", "ID") VALUES (:a1, :a2, :a3, :a4)
select us.sequence_name from all_sequences us where us.sequence_owner = :owner and us.sequence_name = :sequence_name
INSERT INTO "TREASURES" ("LOOTER_ID", "LOOTER_TYPE", "SHIP_ID", "ID") VALUES (:a1, :a2, :a3, :a4).
Expected: 3
Actual: 6
1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
$
```
Since https://github.com/rsim/oracle-enhanced/pull/1490 Oracle enhanced adapter drops its own schema caching called OracleEnhancedAdapter.cache_columns` to use Rails scehema cache
generated by `db:schema:cache:dump`.
By this change some extra sql statements executed at ActiveRecord unit test, which can be
fixed by adding the sql statement to `oracle_ignored`.
* All 17 failures fixed by this pull request:
```ruby
ARCONN=oracle bin/test test/cases/nested_attributes_test.rb:1086
ARCONN=oracle bin/test test/cases/locking_test.rb:308
ARCONN=oracle bin/test test/cases/locking_test.rb:365
ARCONN=oracle bin/test test/cases/dirty_test.rb:351
ARCONN=oracle bin/test test/cases/dirty_test.rb:334
ARCONN=oracle bin/test test/cases/autosave_association_test.rb:192
ARCONN=oracle bin/test test/cases/associations/has_many_associations_test.rb:950
ARCONN=oracle bin/test test/cases/associations/has_many_associations_test.rb:1059
ARCONN=oracle bin/test test/cases/autosave_association_test.rb:627
ARCONN=oracle bin/test test/cases/autosave_association_test.rb:607
ARCONN=oracle bin/test test/cases/autosave_association_test.rb:617
ARCONN=oracle bin/test test/cases/autosave_association_test.rb:641
ARCONN=oracle bin/test test/cases/associations/has_many_through_associations_test.rb:546
ARCONN=oracle bin/test test/cases/associations/has_many_through_associations_test.rb:297
ARCONN=oracle bin/test test/cases/associations/has_many_through_associations_test.rb:586
ARCONN=oracle bin/test test/cases/associations/has_many_through_associations_test.rb:172
ARCONN=oracle bin/test test/cases/associations/has_many_through_associations_test.rb:269
```
|
|
|
|
|
|
|
|
|
| |
`join_scopes` in `PolymorphicReflection` is passed aliased `table`, so
it should be respected for `source_type_scope`.
Closes #13969.
Fixes #13920.
Fixes #15190.
|
| |
|
|
|
|
|
|
|
| |
```
% git grep -n trough
activerecord/test/cases/associations/has_many_through_associations_test.rb:1253: def test_has_many_trough_with_scope_that_has_joined_same_table_with_parent_relation
```
|
| |
|
|\
| |
| | |
delegate scope_for on PolymorphicReflection
|
| | |
|
|/ |
|
| |
|
|\
| |
| | |
Save index order :desc to schema.rb (sqlite). Fixes #30902
|
| |
| |
| |
| |
| | |
Although the sqlite adapter supports index sort orders, they
weren't being written to db/schema.rb.
|
|/
|
|
|
|
|
|
| |
since the minimum version of PostgreSQL currently Rails supports is 9.1,
there is no need to handle if `supports_extensions?`
Refer https://www.postgresql.org/docs/9.1/static/sql-createextension.html
"CREATE EXTENSION"
|
|
|
|
|
|
| |
Currently alias tracker only refer a table name, doesn't respect an
alias name. Should use `join.left.name` rather than
`join.left.table_name`.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
`initialize_internal_metadata_table`
|
| |
|
| |
|
| |
|
|
|
|
| |
object
|
|
|
|
|
|
|
|
| |
It should be shared the count of alias tracking in both INNER/LEFT JOINs
to avoid duplicate aliases.
Fixes #30504.
Closes #30410.
|
|
|
|
|
| |
Currently we have no test for alias tracking with string joins. I've add
test case for that to catch a future regression.
|
|
|
|
|
| |
Since `MocktailDesigner` inherits `DrinkDesigner` and can not be used
alone.
|
|
|
|
| |
It should be initialized only when polymorphic associations.
|
| |
|
| |
|
|
|
|
|
|
|
| |
`InvertibleMigrationTest#test_migrate_enable_and_disable_extension`
to avoid failure of `PostgresqlArrayTest#test_schema_dump_with_shorthand`
which expects `hstore` extension enabled.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
`exists?`
This test covers the case of 02da8aea.
Previously `exists?` was always eager-loading the includes values. But
now it is eager-loaded only when necessary since 07a611e0.
So the case of the eager-loading had not covered in the test.
|
|
|
|
|
|
|
|
| |
We already found the longer sequence name, but we could not consider
whether it was the sequence name created by serial type due to missed a
max identifier length limitation. I've addressed the sequence name
consideration to respect the max identifier length.
Fixes #28332.
|
|
|
|
|
|
|
|
|
|
| |
Currently `AUTO_INCREMENT` is implicitly used in the default primary key
definition. But `AUTO_INCREMENT` is not only used for single column
primary key, but also for composite primary key. In that case,
`auto_increment: true` should be dumped explicitly in the
`db/schema.rb`.
Fixes #30894.
|
|
|
|
|
|
|
|
|
|
| |
This is the fix for the regression of #29848.
In #29848, I've kept existing select list in the subquery for the count
if ORDER BY is given. But it had accidentally affect to GROUP BY
queries also. It should keep the previous behavior in that case.
Fixes #30886.
|
|
|
|
|
|
| |
For investigating the cause of failure.
https://travis-ci.org/rails/rails/jobs/287474883#L797-L799
|
|\
| |
| |
| |
| | |
shioyama/generated_attribute_methods_include_mutex
Include Mutex_m into GeneratedAttributeMethods instead of extending instance
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
parent relation's aliases
Building association scope in join dependency should respect the parent
relation's aliases to avoid using the same alias name more than once.
Fixes #30681.
|
| |
| |
| |
| | |
test cases
|
| |
| |
| |
| |
| | |
`relation.exists?` should reference correct aliases while joining tables
of has_many through associations.
|
|/
|
|
|
|
|
|
| |
* When the adapter is missing, raise an exception that points out config
typos and missing Gemfile entries. (We can assume that a non-builtin
adapter was used since these are always available.)
* When loading an adapter raises a LoadError, prefix its error message
to indicate that the adapter is likely missing an optional dependency.
|
| |
|
| |
|
|
|
|
| |
Since #29301, `arel_attribute` respects a custom table name.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
PostgreSQL 9.1+ introduced range types, and Rails added support for
using this datatype in ActiveRecord. However, the serialization of
`PostgreSQL::OID::Range` was incomplete, because it did not properly
quote the bounds that make up the range. A clear example of this is a
`tsrange`.
Normally, ActiveRecord quotes Date/Time objects to include the
milliseconds. However, the way `PostgreSQL::OID::Range` serialized its
bounds, the milliseconds were dropped. This meant that the value was
incomplete and not equal to the submitted value.
An example of normal timestamps vs. a `tsrange`. Note how the bounds
for the range do not include their milliseconds (they were present in
the ruby Range):
UPDATE "iterations" SET "updated_at" = $1, "range" = $2 WHERE
"iterations"."id" = $3
[["updated_at", "2017-09-23 17:07:01.304864"],
["range", "[2017-09-23 00:00:00 UTC,2017-09-23 23:59:59 UTC]"],
["id", 1234]]
`PostgreSQL::OID::Range` serialized the range by interpolating a
string for the range, which works for most cases, but does not work
for timestamps:
def serialize(value)
if value.is_a?(::Range)
from = type_cast_single_for_database(value.begin)
to = type_cast_single_for_database(value.end)
"[#{from},#{to}#{value.exclude_end? ? ')' : ']'}"
else
super
end
end
(byebug) from = type_cast_single_for_database(value.begin)
2010-01-01 13:30:00 UTC
(byebug) to = type_cast_single_for_database(value.end)
2011-02-02 19:30:00 UTC
(byebug) "[#{from},#{to}#{value.exclude_end? ? ')' : ']'}"
"[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
@sgrif (the original implementer for Postgres Range support) provided
some feedback about where the quoting should occur:
Yeah, quoting at all is definitely wrong here. I'm not sure what I
was thinking in 02579b5, but what this is doing is definitely in the
wrong place. It should probably just be returning a range of
subtype.serialize(value.begin) and subtype.serialize(value.end), and
letting the adapter handle the rest.
`Postgres::OID::Range` now returns a `Range` object, and
`ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting` can now encode
and quote a `Range`:
def encode_range(range)
"[#{type_cast(range.first)},#{type_cast(range.last)}#{range.exclude_end? ? ')' : ']'}"
end
...
encode_range(range)
#=> "['2010-01-01 13:30:00.670277','2011-02-02 19:30:00.745125')"
This commit includes tests to make sure the milliseconds are
preserved in `tsrange` and `tstzrange` columns
|