| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The values infinity and -infinity are supported by both date and
timestamp types.
https://www.postgresql.org/docs/current/static/datatype-datetime.html#DATATYPE-DATETIME-SPECIAL-TABLE
And also, it can not be known whether a value is infinity correctly
unless cast a value.
I've added `QueryAttribute#infinity?` to handle that case.
Closes #27585.
|
|
|
|
|
| |
Since #32028, Rails 6 requires Ruby 2.3+.
No longer needed workaround for Ruby 2.2 "private attribute?" warning.
|
|
|
|
|
|
| |
This reverts commit cf4f05a7d4a2051cf3593bc7c3a6a216e74e797a.
Since Rails 6 requires Ruby 2.4.1+.
|
| |
|
|\
| |
| |
| |
| | |
mohsen-alizadeh/sanitize_empty_and_nil_parameters_passed_to_select
sanitize empty and nil parameters to select #31059
|
| | |
|
| | |
|
| |
| |
| | |
* Add Relation#pick as short-hand for single-value plucks
|
| |
| |
| |
| |
| |
| |
| | |
With #31615 `type_for_attribute` accepts either
a symbol as well as a string. `has_attribute?` and `attribute_alias`
also accept either. Since these methods call `to_s` on the argument,
we no longer need to do that at the call site.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Follow up of #31724.
If `composed_of` objects have multiple mappings, array predicate handler
can not correctly handle the expanded condition.
We need to handle it like polymorphic association objects.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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?
|
| | |
|
|\ \
| | |
| | |
| | | |
Allow unscoping of left_outer_joins
|
| | | |
|
| | |
| | |
| | |
| | | |
Because `Relation` already have Arel `table`.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This is a complete fix to #30995.
Originally alias tracker will only track table aliases on
`Arel::Nodes::Join`, other args are ignored.
Since c5ab6e5, parent aliases hash will be passed then it caused the
regression #30995.
It is enough to pass list of `Arel::Nodes::Join` simply, not need to
pass garbage args which will be ignored.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`find_with_associations`
`find_with_associations` is meaningless name in this point since it just
contain `construct_join_dependency` and `apply_join_dependency`, does
not contain finding anything.
If `apply_join_dependency` returns `relation` and `join_dependency` then
`find_with_associations` is no longer needed.
|
| | |
| | |
| | |
| | |
| | |
| | | |
`relation.exists?` just wants to know if there is a result or not, does
not need the exact records matched. Therefore, an intermediate SELECT
query for eager loading is not necessary.
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
We can use `relation.last(index)[-index]` instead of loading all records
when using reversible order because `last` will call `reverse_order`.
|
| | |
| | |
| | |
| | |
| | |
| | | |
Currently `last` with `offset` behaves incorrectly because `offset` can
not be reversed like `limit`. Therefore, `offset` should also be handled
like `limit`.
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
This is a partial revert of #26182. There is no reason to change the
default value.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`association_primary_key` in `TableMetadata`
Because `join_primary_key` is called by `join_keys` and it is to
abstract calling `association_primary_key`.
|
| | |
| | |
| | |
| | | |
Like other query bang methods.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | |
| | |
| | | |
Previously table name qualified `*` is used in that case. If it is not
qualified with a table name, an ambiguous column name error will occur
when using JOINs.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Currently, sanitize methods are private. So need `send` to use from
outside class.
However, sometimes want to use sanitize methods from outside Class when
want to generate SQL including multiple tables like search.
In order to avoid using `send` in such a case, changed methods to public.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
- #30980 introcuded a change to not use `Arel.star` when model have ignored columns, a query used to look like `SELECT *. FROM developers` whereas now it would like `SELECT column1, column2 FROM developers`
- If a column has the same name has a reserved database specific keyword (such as key, where ...) then the query would fail because the names aren't quoted
- Quoting almost always happen unless we use a `from` clause in the query https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1052
- This PR cast all columns name to symbols in order for the quoting logic to be picked up https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1054-L1055
- A reproduction script can be found here https://gist.github.com/Edouard-chin/f56d464a0adcb76962afc1a9134a1536
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | | |
ref https://github.com/rails/rails/pull/22653
|
| | | |
|
| | |
| | |
| | |
| | | |
Make it clear that `exists?` can be chained onto a relation
|
|\ \ \
| | | |
| | | |
| | | | |
Disallow raw SQL in dangerous AR methods
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | |
| | | |
| | | |
| | | | |
with Arel SQL literator which overrides #concat
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
| | | | |
|
|\ \ \ \
| |_|_|/
|/| | | |
Do not use `Arel.star` when `ignored_columns`
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
If there are any ignored columns, we will now list out all columns we
want to be returned from the database.
Includes a regression test.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`joins_values.partition` will break joins values order. It should be
kept as user intended order.
Fixes #15488.
|
| | | |
| | | |
| | | |
| | | | |
`CollectionProxy`
|
| | | |
| | | |
| | | |
| | | | |
Fixes #21577.
|