| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
Preprocess association query handling in predicate builder
|
| |
| |
| |
| | |
Because `RelationHandler` uses `value.arel`.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently association query is handled as a postprocess. This has two
problems.
1. When `value` is a `Hash`, we need to skip the postprocess using
`next`.
2. `can_be_bound?` should return false if
`table.associated_with?(column_name)` is true (pass to the postprocess).
These are unneeded if preprocessing association query handling.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Fixes a regression introduced in
22ca710f20c3c656811df006cbf1f4dbc359f7a6 where Relation#unscope with a
specific where value (vs unscoping the entire where clause) could result
in the wrong binds being left on the query.
This was caused by an index variable not being incremented properly.
|
|/
|
|
|
|
|
| |
Since b644964b `ActiveRecord::Relation` includes `Enumerable` so
delegating `collect`, `all?`, and `include?` are also unneeded.
`collect` without block returns `Enumerable` without preloading by that.
We should use `load` rather than `collect` for force loading.
|
|
|
|
|
|
|
|
|
|
| |
This fixes CI failure due to 48f3be8c.
`Enumerable#uniq` was introduced since Ruby 2.4. We should delegate
`uniq` to `records` explicitly.
And since b644964b `ActiveRecord::Relation` includes `Enumerable` so
delegating `map` is unneeded.
|
|\
| |
| | |
Allow order to be given expressions as hash keys
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When `order` is given a hash, the keys are currently assumed to be
attribute names and are quoted as such in the query, which makes it
impossible to pass an expression instead:
Post.order("LENGTH(title)" => :asc).last
# SELECT `posts`.* FROM `posts` ORDER BY `posts`.`LENGTH(title)` DESC LIMIT 1
If the key is an `Arel::Nodes::SqlLiteral`, we now use it directly in
the query. This provides a way to build a relation with a complex order
clause that can still be reversed with `reverse_order` or `last`.
|
|\ \
| | |
| | | |
Simply forward `Calculations#count` to `Enumerable#count`
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Follow up of #24203.
Since b644964b `ActiveRecord::Relation` includes `Enumerable` so it is
enough to call `super` simply.
|
|/ / |
|
|\ \
| |/
|/| |
Fix `find_nth` with `limit_value`
|
| |
| |
| |
| |
| | |
If the `index` exceeds a `limit`, simply return an empty result without
querying the database.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a grouped calculation contains a having clause that references a
selected value, we need to include that selected value in the query.
Postgres doesn't support referencing a selected value in a having
clause, but other databases do; we can skip the test on the pg adapter
but run it for the others.
This was fixed before in 9a298a162c16e019fe6971e563e7f4916e86ced6, but
the test coverage was lost in 5a05207d99b7e2678f9b42db2d9ffc21ec2c8c3b.
The fix regressed in 6311975fb3c02f50730fd1e11b8dba8dd9c05306 and was
removed in 97d46c17ea9113b0ce970167f5208c8d9170915c.
|
|\
| |
| | |
Remove duplicated private method in ActiveRecord::FinderMethods
|
| | |
|
|/
|
|
|
| |
`select_values` is a local variable defined at previous line.
`select_values += select_values` is totally useless.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`DISTINCT` clause is applied inside aggregate function by
`operation_over_aggregate_column` if needed. Unneeded outside aggregate
function.
```ruby
# Before
author.unique_categorized_posts.count
# => SELECT DISTINCT COUNT(DISTINCT "posts"."id") FROM "posts" INNER JOIN "categorizations" ON "posts"."id" = "categorizations"."post_id" WHERE "categorizations"."author_id" = ? [["author_id", 2]]
# After
author.unique_categorized_posts.count
# => SELECT COUNT(DISTINCT "posts"."id") FROM "posts" INNER JOIN "categorizations" ON "posts"."id" = "categorizations"."post_id" WHERE "categorizations"."author_id" = ? [["author_id", 2]]
```
Closes #27615
|
|\
| |
| | |
Fix unscope with subquery
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
Currently cannot unscope subquery properly.
This commit fixes the issue.
Fixes #26323.
|
|\ \
| | |
| | |
| | |
| | | |
kenta-s/add-methods-back-to-array-delegation-from-ar-relation
Delegate `to_sentence` and `to_fomatted_s` to `records`
|
| | | |
|
| | |
| | |
| | |
| | | |
This reverts commit 28977f1fa3d7b15c1608174a165e60b71ddf3995.
|
|\ \ \
| | | |
| | | |
| | | |
| | | | |
kamipo/decouple_building_arel_ast_for_uniqueness_validator
Decouple the building Arel ASTs for uniqueness validator
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Currently uniqueness validator is coupled with building Arel ASTs.
This commit extracts `WhereClauseFactory#build_for_case_sensitive` for
decouple the building Arel ASTs.
|
| |/ /
|/| |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
If select clause is specified and last column has a column alias,
additional column alias causes a statement invalid.
Add test coverage for counting a single column with NULL values.
Fixes #27676, #27682, and #27705.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
|
| | | |
|
| | |
| | |
| | |
| | | |
find and exists?
|
| | |
| | |
| | |
| | | |
Closes #14640
|
| | | |
|
| | |
| | |
| | |
| | | |
provided.
|
| | | |
|
| | | |
|
| | | |
|
|\ \ \
| | | |
| | | | |
Remove extracting `polymorphic_base_class` for `Array` in `AssociationQueryValue`
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`AssociationQueryValue`
It is handled by `PolymorphicArrayValue`.
|
| |/ /
|/| |
| | |
| | |
| | |
| | | |
Some methods were added to public API in
5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of
the public API.
|
| | | |
|
| | | |
|
| | | |
|
| |/
|/|
| |
| | |
Raise `ActiveRecord::RangeError` when values that executed are out of range.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
9c9fb19 changed the behaviour of the _ids= setters for associations to
raise an AssociationTypeMismatch when unknown IDs are given:
Class: <ActiveRecord::AssociationTypeMismatch>
Message: <"Developer(#43811860) expected, got NilClass(#16732720)">
This restores the original ActiveRecord::RecordNotFound exception with a
much clearer error message:
Class: <ActiveRecord::RecordNotFound>
Message: <"Couldn't find all Developers with 'id': (1, -9999) [WHERE \"contracts\".\"company_id\" = ?] (found 1 results, but was looking for 2)">
Fixes #25719
|
|\ \
| | |
| | | |
Should except `:distinct` rather than `:order` for `exists?`
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Records fetching order is very important for performance if `limit` is
presented. Should not except the order in the case.
And `exists?` replaces select list to `1 AS one` therefore `:distinct`
is useless (`DISTINCT 1 AS one`). And PostgreSQL raises the following
error if `:distinct` and `:order` are used in the same time.
```
ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
```
|
|/ /
| |
| |
| | |
All query methods calls `spawn` and bang method, but only `none` is not.
|
| |
| |
| |
| |
| | |
If `limit_value` is presented, records fetching order is very important
for performance. Should not unscope the order in the case.
|