Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve all sqlalchemy.exc.RemovedIn20Warnings #123

Merged
merged 8 commits into from Aug 7, 2023

Conversation

jpvanhal
Copy link
Member

@jpvanhal jpvanhal commented Aug 7, 2023

Refs #111

Set up pytest to raise exception for `sqlalchemy.exc.RemovedIn20Warning`
warnings by default. Ignore the warnings that are triggered by the test
suite.

Refs #111
Use `text()` construct to wrap plain string SQL statements to avoid the
following `RemovedIn20Warning`:

    Using plain strings to indicate SQL statements without using the
    text() construct is  deprecated and will be removed in version 2.0.
    Ensure plain SQL statements are passed using the text() construct.

Refs #111
The `declarative_base()` function has moved to `sqlalchemy.orm` in
SQLAlchemy 2.0. Change the docs to use the new location.

Refs #111
The `declarative_base()` function has moved to `sqlalchemy.orm` in
SQLAlchemy 2.0. Change the tests to use the new location.

Refs #111
The `autoload` parameter is deprecated in SQLAlchemy 1.4 and will be
removed in version 2.0. The `autoload_with` parameter is already used,
so just remove the deprecated `autoload` parameter.

Refs #111.
Use `Engine.begin()` to start a transaction and `Connection.execute()`
over `Engine.execute()` in tests to resolve the following warnings:

    The Engine.execute() method is considered legacy as of the 1.x
    series of SQLAlchemy and will be removed in 2.0. All statement
    execution in SQLAlchemy 2.0 is performed by the Connection.execute()
    method of Connection, or in the ORM by the Session.execute() method
    of Session.

    The current statement is being autocommitted using implicit
    autocommit, which will be removed in SQLAlchemy 2.0. Use the
    .begin() method of Engine or Connection in order to use an explicit
    transaction for DML and DDL statements.

Refs #111
Use SQLAlchemy's compilation extension to build the SQL for creating and
dropping the search functions and triggers. This resolves the following
deprecation warning:

    The connection.execute() method in SQLAlchemy 2.0 will accept
    parameters as a single dictionary or a single sequence of
    dictionaries only. Parameters passed as keyword arguments, tuples or
    positionally oriened dictionaries and/or tuples will no longer be
    accepted.

BREAKING CHANGE: `quote_identifier` function has been removed.

BREAKING CHANGE: `SearchManager.search_function_ddl` method has been
removed. Use `CreateSearchFunctionSQL(column)` instead.

BREAKING CHANGE: `SearchManager.search_trigger_ddl` method has been
removed. Use `CreateSearchTriggerSQL(column)` instead.

Refs #111
Wrap the raw SQL queries passed to `Connection.execute()` with `text()`
construct. This resolves the following deprecation warning:

    Passing a string to Connection.execute() is deprecated and will be
    removed in version 2.0.  Use the text() construct, or the
    Connection.exec_driver_sql() method to invoke a driver-level SQL
    string.

Refs #111
@jpvanhal jpvanhal force-pushed the resolve-sqlalchemy-2-warnings branch from 1030f92 to 54f7895 Compare August 7, 2023 20:03
@jpvanhal jpvanhal merged commit 2738f65 into master Aug 7, 2023
12 checks passed
@jpvanhal jpvanhal deleted the resolve-sqlalchemy-2-warnings branch August 7, 2023 20:05
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.

None yet

1 participant