| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
This restores an ability that `update` with ids on a relation which is
described at https://github.com/rails/rails/issues/33470#issuecomment-411203013.
I personally think that the `update` with two arguments on a relation is
not a designed feature, since that is totally not using a relation
state, and also is not documented.
But removing any feature should not be suddenly happened in a stable
version even if that is not documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since 9ac7dd4, class level `update`, `destroy`, and `delete` were placed
in the `Persistence` module as class methods.
But `Relation#update` without passing ids which was introduced at #11898
is not a class method, and it was caused the extra scoping regression
#33470.
I moved the relation method back into the `Relation` to fix the
regression.
Fixes #33470.
|
|\
| |
| | |
Add `touch_all` method to `ActiveRecord::Relation`
|
| | |
|
|/
|
|
|
| |
This autocorrects the violations after adding a custom cop in
3305c78dcd.
|
|
|
|
| |
Active Record distinct & order #count regression
|
|
|
| |
Add #create_or_find_by to lean on unique constraints
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
driving table
This is a regression caused by 6beb4de.
In PostgreSQL, ORDER BY expressions must appear in SELECT list when
using DISTINCT.
When using `count(:all)` with eager loading, Active Record enforces
DISTINCT to count the driving table records only. 6beb4de was caused the
regression because `count(:all)` with DISTINCT path no longer removes
ORDER BY.
We need to ignore ORDER BY when DISTINCT is enforced, otherwise not
always generated valid SQL for PostgreSQL.
Fixes #31783.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Most of the time the table and predicate_builder
passed to Relation.new are exactly the
arel_table and predicate builder of the
given klass. This uses klass.arel_table
and klass.predicate_builder as the defaults,
so we don't have to pass them in most cases.
This does change the signaure of both Relation and
AssocationRelation. Are we ok with that?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently `count(:all)` with `distinct` doesn't work correctly because
SELECT list is always replaced to `*` or primary key in that case even
if having custom SELECT list.
And also, PostgreSQL has a limitation that ORDER BY expressions must
appear in select list for SELECT DISTINCT.
Therefore, we should not replace custom SELECT list when using
`count(:all)` with `distinct`.
Closes #31277.
|
| |
|
|
|
|
|
|
| |
Arel doesn't support subselect generation for DELETE unlike UPDATE yet,
but we already have that generation in connection adapters. We can
simply use the subselect generated by that one.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This regression was caused at 213796fb due to polymorphic predicates are
combined by `Arel::Nodes::And`. But I'd like to keep that combined
because it would help inverting polymorphic predicates correctly
(e9ba12f7), and we can collect equality nodes regardless of combined by
`Arel::Nodes::And` (`a AND (b AND c) AND d` == `a AND b AND c AND d`).
This change fixes the regression to collect equality nodes in
`Arel::Nodes::And` as well.
Fixes #31338.
|
|\
| |
| |
| | |
Disallow raw SQL in dangerous AR methods
|
| | |
|
| | |
|
| |
| |
| |
| | |
with Arel SQL literator which overrides #concat
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
https://travis-ci.org/rails/rails/jobs/300163487#L1974
|
| |
| |
| |
| | |
Fixes #21577.
|
|/ |
|
|
|
|
| |
test cases
|
| |
|
|
|
|
| |
Since #29301, `arel_attribute` respects a custom table name.
|
|
|
|
|
|
|
|
| |
I do not want to set the expectation that any enumerable object should
behave this way, but this case in particular comes up frequently enough
that I'm caving on this one.
Fixes #30684.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A common source of bugs and code bloat within Active Record has been the
need for us to maintain the list of bind values separately from the AST
they're associated with. This makes any sort of AST manipulation
incredibly difficult, as any time we want to potentially insert or
remove an AST node, we need to traverse the entire tree to find where
the associated bind parameters are.
With this change, the bind parameters now live on the AST directly.
Active Record does not need to know or care about them until the final
AST traversal for SQL construction. Rather than returning just the SQL,
the Arel collector will now return both the SQL and the bind parameters.
At this point the connection adapter will have all the values that it
had before.
A bit of this code is janky and something I'd like to refactor later. In
particular, I don't like how we're handling associations in the
predicate builder, the special casing of `StatementCache::Substitute` in
`QueryAttribute`, or generally how we're handling bind value replacement
in the statement cache when prepared statements are disabled.
This also mostly reverts #26378, as it moved all the code into a
location that I wanted to delete.
/cc @metaskills @yahonda, this change will affect the adapters
Fixes #29766.
Fixes #29804.
Fixes #26541.
Close #28539.
Close #24769.
Close #26468.
Close #26202.
There are probably other issues/PRs that can be closed because of this
commit, but that's all I could find on the first few pages.
|
|\
| |
| | |
Fix a failued AR test when using OracleAdapter
|
| | |
|
|\ \
| | |
| | | |
Use frozen-string-literal in ActiveRecord
|
| |/ |
|
|/
|
|
|
|
|
|
| |
This reverts commit b6ad4052d18e4b29b8a092526c2beef013e2bf4f.
This is not something that the majority of Active Record should be
testing or care about. We should look at having fewer places rely on
these details, not make it easier to rely on them.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Without this fix, `JoinDependency` doesn't use a custom table alias:
```
% ARCONN=sqlite3 be ruby -w -Itest test/cases/relations_test.rb -n test_using_a_custom_table_with_joins_affects_the_wheres
Using sqlite3
Run options: -n test_using_a_custom_table_with_joins_affects_the_wheres --seed 14531
E
Error:RelationTest#test_using_a_custom_table_with_joins_affects_the_wheres:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: posts.author_id: SELECT "omg_posts".* FROM "posts" "omg_posts" INNER JOIN "authors" ON "authors"."id" = "posts"."author_id" WHERE "omg_posts"."title" = ? LIMIT ?
```
|
|\
| |
| | |
Extract `NullRelationTest` from `RelationTest`
|
| |
| |
| |
| |
| | |
`test/cases/relations_test.rb` file has too much lines (2000 over).
So I extracted `NullRelationTest` to the dedicated file.
|
|\ \
| | |
| | |
| | |
| | | |
kamipo/remove_outdated_test_scoped_responds_to_delegated_methods
Remove outdated `test_scoped_responds_to_delegated_methods`
|
| |/
| |
| |
| |
| |
| |
| |
| | |
This test was added at 74ed123 to ensure `respond_to?` delegate methods
to `Array` and `arel_table`. But array method delegation was removed at
9d79334 in favor of including `Enumerable`. And now `Relation` has
`insert`, `update`, and `delete` methods (63480d2, 8d31c9f, d5f9173).
So this delegation test is already outdated.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Without this fix, SELECT clause doesn't use a custom table alias name:
```
% ARCONN=sqlite3 be ruby -w -Itest test/cases/relations_test.rb -n test_using_a_custom_table_affects_the_wheres
Using sqlite3
Run options: -n test_using_a_custom_table_affects_the_wheres --seed 31818
E
Error:
RelationTest#test_using_a_custom_table_affects_the_wheres:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: posts: SELECT "posts".* FROM "posts" "omg_posts" WHERE "omg_posts"."title" = ? LIMIT ?
```
|
|/
|
|
|
|
|
| |
This is related with #27680.
Since `where_values_hash` keys constructed by `where` are string, so we
need `stringify_keys` to `create_with_value` before merging it.
|
|
|
|
|
|
|
|
|
|
|
| |
The `find_each`, `find_in_batches` and `in_batches` APIs usually operate
on large numbers of records, where it's preferable not to load them all
into memory at once.
If the query cache is enabled, it will hold onto the query results until
the end of the execution context (request/job), which means the memory
used is still proportional to the total number of records. These queries
are typically not repeated, so the query cache isn't desirable here.
|
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| |
|
|\
| |
| | |
`Relation#locked?` should not build arel
|
| |
| |
| |
| |
| | |
The delegation was needed since passing `relation` with
`relation.bound_attributes`. It should use `relation.arel` in that case.
|
| | |
|