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

Add support for SQLAlchemy 2.0 #111

Closed
rubenwardy opened this issue May 13, 2023 · 0 comments · Fixed by #125
Closed

Add support for SQLAlchemy 2.0 #111

rubenwardy opened this issue May 13, 2023 · 0 comments · Fixed by #125

Comments

@rubenwardy
Copy link

As an example, sync_trigger gives you the following error:

TypeError: Additional arguments should be named _, got 'autoload'

File "/home/cdb/migrations/versions/2f3c3597c78d_.py", line 27, in upgrade
    sync_trigger(conn, 'package', 'search_vector', ["title", "short_desc", "desc"])
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy_searchable/__init__.py", line 446, in sync_trigger
    table = sa.Table(
  File "<string>", line 2, in __new__
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 277, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 428, in __new__
    return cls._new(*args, **kw)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 482, in _new
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 478, in _new
    table.__init__(name, metadata, *args, _no_init=False, **kw)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 848, in __init__
    self._extra_kwargs(**kw)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/schema.py", line 996, in _extra_kwargs
    self._validate_dialect_kwargs(kwargs)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/base.py", line 562, in _validate_dialect_kwargs
    raise TypeError(
TypeError: Additional arguments should be named <dialectname>_<argument>, got 'autoload'
jpvanhal added a commit that referenced this issue Aug 7, 2023
Set environment variable `SQLALCHEMY_WARN_20=1` to show all SQLAlchemy
2.0 deprecation warnings when running the tests with tox.

Refs #111
jpvanhal added a commit that referenced this issue Aug 7, 2023
Set environment variable `SQLALCHEMY_WARN_20=1` to show all SQLAlchemy
2.0 deprecation warnings when running the tests with tox.

Refs #111
jpvanhal added a commit that referenced this issue Aug 7, 2023
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
jpvanhal added a commit that referenced this issue Aug 7, 2023
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
jpvanhal added a commit that referenced this issue Aug 7, 2023
The `declarative_base()` function has moved to `sqlalchemy.orm` in
SQLAlchemy 2.0. Change the docs to use the new location.

Refs #111
jpvanhal added a commit that referenced this issue Aug 7, 2023
The `declarative_base()` function has moved to `sqlalchemy.orm` in
SQLAlchemy 2.0. Change the tests to use the new location.

Refs #111
jpvanhal added a commit that referenced this issue Aug 7, 2023
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.
jpvanhal added a commit that referenced this issue Aug 7, 2023
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
jpvanhal added a commit that referenced this issue Aug 7, 2023
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`. Use
`CreateSearchTriggerSQL(column)` instead.

Refs #111
jpvanhal added a commit that referenced this issue Aug 7, 2023
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 added a commit that referenced this issue Aug 7, 2023
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
jpvanhal added a commit that referenced this issue Aug 7, 2023
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 added a commit that referenced this issue Aug 7, 2023
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
jpvanhal added a commit that referenced this issue Aug 7, 2023
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
jpvanhal added a commit that referenced this issue Aug 7, 2023
The `declarative_base()` function has moved to `sqlalchemy.orm` in
SQLAlchemy 2.0. Change the docs to use the new location.

Refs #111
jpvanhal added a commit that referenced this issue Aug 7, 2023
The `declarative_base()` function has moved to `sqlalchemy.orm` in
SQLAlchemy 2.0. Change the tests to use the new location.

Refs #111
jpvanhal added a commit that referenced this issue Aug 7, 2023
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.
jpvanhal added a commit that referenced this issue Aug 7, 2023
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
jpvanhal added a commit that referenced this issue Aug 7, 2023
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
jpvanhal added a commit that referenced this issue Aug 7, 2023
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 added a commit that referenced this issue Aug 7, 2023
Pass `future=True` flag to `create_engine`, `sessionmaker` and `Session`
in tests.

Refs #111.
jpvanhal added a commit that referenced this issue Aug 7, 2023
Pass `future=True` flag to `create_engine`, `sessionmaker` and `Session`
in tests.

Refs #111.
jpvanhal added a commit that referenced this issue Aug 7, 2023
Test against SQLAlchemy 2.0 and update the SQLAlchemy dependency to
remove the `<1.5` version restriction.

Closes #111.
jpvanhal added a commit that referenced this issue Aug 7, 2023
Test against SQLAlchemy 2.0 and update the SQLAlchemy dependency to
remove the `<1.5` version restriction.

Closes #111. Closes #109.
jpvanhal added a commit that referenced this issue Aug 7, 2023
Test against SQLAlchemy 2.0 and update the SQLAlchemy dependency to
remove the `<1.5` version restriction.

Closes #111. Closes #109.
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 a pull request may close this issue.

1 participant