Skip to content

Conversation

miketheman
Copy link
Member

SQLAlchemy Wiki updated their suggested implementation circa 2020.
https://github.com/sqlalchemy/sqlalchemy/wiki/RangeQuery-and-WindowedRangeQuery

The existing code raises this deprecation warning:

RemovedIn20Warning: The Query.from_self() method is considered legacy
as of the 1.x series of SQLAlchemy and will be removed in 2.0.
The new approach is to use the orm.aliased() construct in conjunction
with a subquery.
See the section "Selecting from the query itself as a subquery" in the
2.0 migration notes for an example.

Instead of trying to update the syntax, use their suggested query which emits the same behavior.

This is used in one place only - the nightly reindex() task, so it's low risk.

@miketheman miketheman requested a review from a team as a code owner June 3, 2023 00:43
@miketheman miketheman force-pushed the miketheman/refactor-windowed-query branch 3 times, most recently from 18c086b to fa443cd Compare June 3, 2023 01:31
@miketheman miketheman marked this pull request as draft June 3, 2023 01:53
@miketheman miketheman force-pushed the miketheman/refactor-windowed-query branch 2 times, most recently from 3c834ed to 00fbb72 Compare June 7, 2023 14:17
SQLAlchemy Wiki updated their suggested implementation circa 2020.

The existing code raises this deprecation warning:

```
RemovedIn20Warning: The Query.from_self() method is considered legacy
as of the 1.x series of SQLAlchemy and will be removed in 2.0.
The new approach is to use the orm.aliased() construct in conjunction
with a subquery.
See the section "Selecting from the query itself as a subquery" in the
2.0 migration notes for an example.
```

Instead of trying to update the syntax, use their suggested query which
emits the same behavior.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
@miketheman miketheman force-pushed the miketheman/refactor-windowed-query branch from 00fbb72 to ad287f8 Compare June 7, 2023 21:34
@miketheman miketheman marked this pull request as ready for review June 7, 2023 21:35
@miketheman miketheman enabled auto-merge (squash) June 8, 2023 14:13
@miketheman miketheman merged commit d972367 into pypi:main Jun 8, 2023
@miketheman miketheman deleted the miketheman/refactor-windowed-query branch June 8, 2023 14:32
miketheman added a commit to miketheman/warehouse that referenced this pull request Apr 9, 2024
The upstream wiki has been updated. This implements the desired changes.
See: https://github.com/sqlalchemy/sqlalchemy/wiki/RangeQuery-and-WindowedRangeQuery

One notable difference is that the column must be comparable/sortable
with a `ge` operator, and the implementation of UUID doesn't appear to
work. Use `.name` instead.

Previously refactored in pypi#13845

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
miketheman added a commit to miketheman/warehouse that referenced this pull request Apr 9, 2024
The upstream wiki has been updated. This implements the desired changes.
See: https://github.com/sqlalchemy/sqlalchemy/wiki/RangeQuery-and-WindowedRangeQuery

One notable difference is that the column must be comparable/sortable
with a `ge` operator, and the implementation of UUID doesn't appear to
work. Use `.name` instead.

Previously refactored in pypi#13845

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
miketheman added a commit to miketheman/warehouse that referenced this pull request Apr 9, 2024
The upstream wiki has been updated. This implements the desired changes.
See: https://github.com/sqlalchemy/sqlalchemy/wiki/RangeQuery-and-WindowedRangeQuery

One notable difference is that the column must be comparable/sortable
with a `ge` operator, and the implementation of UUID doesn't appear to
work. Use `.name` instead.

Previously refactored in pypi#13845

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
ewdurbin pushed a commit that referenced this pull request Apr 10, 2024
The upstream wiki has been updated. This implements the desired changes.
See: https://github.com/sqlalchemy/sqlalchemy/wiki/RangeQuery-and-WindowedRangeQuery

One notable difference is that the column must be comparable/sortable
with a `ge` operator, and the implementation of UUID doesn't appear to
work. Use `.name` instead.

Previously refactored in #13845

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants