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

SQLAlchemy 1.4 support + Move CI to GitHub workflows #506

Merged
merged 59 commits into from
Apr 12, 2021

Commits on Jul 9, 2020

  1. fix database existence check

    follow up to kvesteri#372
    bernt-matthias committed Jul 9, 2020
    Configuration menu
    Copy the full SHA
    6e11f3f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    36e765b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    743aa21 View commit details
    Browse the repository at this point in the history
  4. fix dialect_name

    Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
    bernt-matthias and nsoranzo committed Jul 9, 2020
    Configuration menu
    Copy the full SHA
    15dc668 View commit details
    Browse the repository at this point in the history
  5. optimize execution order

    Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
    bernt-matthias and nsoranzo authored Jul 9, 2020
    Configuration menu
    Copy the full SHA
    527b885 View commit details
    Browse the repository at this point in the history

Commits on Jul 15, 2020

  1. database_exists fix return

    - postgres: return for the first positive test
    - use immutable for default argument
    bernt-matthias committed Jul 15, 2020
    Configuration menu
    Copy the full SHA
    37bb37b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4b396d8 View commit details
    Browse the repository at this point in the history
  3. use None as default

    Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
    bernt-matthias and nsoranzo authored Jul 15, 2020
    Configuration menu
    Copy the full SHA
    6dd16e7 View commit details
    Browse the repository at this point in the history
  4. break if successful

    Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
    bernt-matthias and nsoranzo authored Jul 15, 2020
    Configuration menu
    Copy the full SHA
    7e41e85 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    e481582 View commit details
    Browse the repository at this point in the history

Commits on Jul 16, 2020

  1. use Null connection pool and close connections

    - use a connection (which is closed automatically) for
      data base existence check
    - explicitely use Null connection pool
    
    already with the 1st change disposal of the engine (which closes all
    open connections) is not necessary anymore. with the second change
    we are completely sure.
    bernt-matthias committed Jul 16, 2020
    Configuration menu
    Copy the full SHA
    74b3513 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    acb681c View commit details
    Browse the repository at this point in the history

Commits on Jul 28, 2020

  1. Configuration menu
    Copy the full SHA
    7908606 View commit details
    Browse the repository at this point in the history

Commits on Jul 29, 2020

  1. Configuration menu
    Copy the full SHA
    f509f38 View commit details
    Browse the repository at this point in the history

Commits on Dec 25, 2020

  1. Add support for SQLAlchemy 1.4

    Import _ColumnEntity from sqlalchemy.orm.context if importing from
    .query fails.
    
    And while checking if database_exists, use url.set() as URL object is
    now immutable.
    cnu committed Dec 25, 2020
    Configuration menu
    Copy the full SHA
    504a92b View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2021

  1. 2 Configuration menu
    Copy the full SHA
    0931cae View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2021

  1. Removed the try..except constructs to set the database. Now checking …

    …*once* the version of sqlalchemy in use and deciding *once* how to change the database address. Using a wrapping function ('set_database_from_url') to simplify the code.
    lucventurini committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    1f09558 View commit details
    Browse the repository at this point in the history
  2. Cleanups

    nsoranzo committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    6646a47 View commit details
    Browse the repository at this point in the history
  3. Use execution_options() method of Connection

    to set the transaction isolation level to autocommit for PostgreSQL.
    nsoranzo committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    1db87e1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    36dca77 View commit details
    Browse the repository at this point in the history
  5. Lint fixes

    nsoranzo committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    53cf0bc View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    86cf5b2 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    b3d75c3 View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2021

  1. Use with engine.connect() context manager

    Consolidate autocommit across drivers that support it, xref.
    kvesteri#494 and
    fix kvesteri#486 .
    nsoranzo committed Mar 18, 2021
    Configuration menu
    Copy the full SHA
    4f52578 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    57e3f16 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c791211 View commit details
    Browse the repository at this point in the history

Commits on Mar 19, 2021

  1. Update tests for changes in create_database

    to use `with engine.connect()` context manager (commit
    4f52578 )
    nsoranzo committed Mar 19, 2021
    Configuration menu
    Copy the full SHA
    36a24eb View commit details
    Browse the repository at this point in the history
  2. Install the version of pg8000 recommended by SQLAlchemy 1.3

    when testing.
    
    xref. kvesteri#500
    
    Fix the following exception:
    
    ```
    _____________________________________________________________________________ TestDatabasePostgresPg8000.test_create_and_drop _____________________________________________________________________________
    
    self = <tests.functions.test_database.TestDatabasePostgresPg8000 object at 0x7f3b3da76490>, dsn = 'postgresql+pg8000://postgres:postgres@localhost/db_to_test_create_and_drop_via_pg8000_driver'
    
        def test_create_and_drop(self, dsn):
    >       assert not database_exists(dsn)
    
    tests/functions/test_database.py:15:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    sqlalchemy_utils/functions/database.py:488: in database_exists
        return bool(_get_scalar_result(engine, text))
    sqlalchemy_utils/functions/database.py:443: in _get_scalar_result
        with engine.connect() as conn:
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:2263: in connect
        return self._connection_cls(self, **kwargs)
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:104: in __init__
        else engine.raw_connection()
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:2369: in raw_connection
        return self._wrap_pool_connect(
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:2336: in _wrap_pool_connect
        return fn()
    .venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py:304: in unique_connection
        return _ConnectionFairy._checkout(self)
    .venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py:778: in _checkout
        fairy = _ConnectionRecord.checkout(pool)
    .venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py:495: in checkout
        rec = pool._do_get()
    .venv/lib/python3.8/site-packages/sqlalchemy/pool/impl.py:241: in _do_get
        return self._create_connection()
    .venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py:309: in _create_connection
        return _ConnectionRecord(self)
    .venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py:440: in __init__
        self.__connect(first_connect_check=True)
    .venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py:664: in __connect
        pool.dispatch.first_connect.for_modify(
    .venv/lib/python3.8/site-packages/sqlalchemy/event/attr.py:314: in exec_once_unless_exception
        self._exec_once_impl(True, *args, **kw)
    .venv/lib/python3.8/site-packages/sqlalchemy/event/attr.py:285: in _exec_once_impl
        self(*args, **kw)
    .venv/lib/python3.8/site-packages/sqlalchemy/event/attr.py:322: in __call__
        fn(*args, **kw)
    .venv/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py:1406: in go
        return once_fn(*arg, **kw)
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py:199: in first_connect
        dialect.initialize(c)
    .venv/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/pg8000.py:215: in initialize
        super(PGDialect_pg8000, self).initialize(connection)
    .venv/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/base.py:2624: in initialize
        super(PGDialect, self).initialize(connection)
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py:311: in initialize
        self.server_version_info = self._get_server_version_info(
    .venv/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/base.py:2869: in _get_server_version_info
        v = connection.execute("select version()").scalar()
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1003: in execute
        return self._execute_text(object_, multiparams, params)
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1172: in _execute_text
        ret = self._execute_context(
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1316: in _execute_context
        self._handle_dbapi_exception(
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1514: in _handle_dbapi_exception
        util.raise_(exc_info[1], with_traceback=exc_info[2])
    .venv/lib/python3.8/site-packages/sqlalchemy/util/compat.py:182: in raise_
        raise exception
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1294: in _execute_context
        result = context._setup_crud_result_proxy()
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py:1258: in _setup_crud_result_proxy
        result = self.get_result_proxy()
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py:1233: in get_result_proxy
        return result.ResultProxy(self)
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py:775: in __init__
        self._init_metadata()
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py:807: in _init_metadata
        self._metadata = ResultMetaData(self, cursor_description)
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py:290: in __init__
        raw = self._merge_cursor_description(
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py:496: in _merge_cursor_description
        return [
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py:496: in <listcomp>
        return [
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py:616: in _merge_cols_by_none
        for (
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    self = <sqlalchemy.engine.result.ResultMetaData object at 0x7f3b3daa4a90>, context = <sqlalchemy.dialects.postgresql.pg8000.PGExecutionContext_pg8000 object at 0x7f3b3dda7100>
    cursor_description = [('version', 25, None, None, None, None, ...)]
    
        def _colnames_from_description(self, context, cursor_description):
            """Extract column names and data types from a cursor.description.
    
            Applies unicode decoding, column translation, "normalization",
            and case sensitivity rules to the names based on the dialect.
    
            """
    
            dialect = context.dialect
            case_sensitive = dialect.case_sensitive
            translate_colname = context._translate_colname
            description_decoder = (
                dialect._description_decoder
                if dialect.description_encoding
                else None
            )
            normalize_name = (
                dialect.normalize_name if dialect.requires_name_normalize else None
            )
            untranslated = None
    
            self.keys = []
    
            for idx, rec in enumerate(cursor_description):
                colname = rec[0]
                coltype = rec[1]
    
                if description_decoder:
    >               colname = description_decoder(colname)
    E               TypeError: expected bytes, str found
    
    .venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py:545: TypeError
    ```
    nsoranzo committed Mar 19, 2021
    Configuration menu
    Copy the full SHA
    151fc8c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6146a76 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    1c25400 View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2021

  1. Configuration menu
    Copy the full SHA
    2eecaa9 View commit details
    Browse the repository at this point in the history
  2. Fix `AttributeError: type object 'User' has no attribute '_decl_class…

    …_registry'`
    
    and similar messages for other objects.
    nsoranzo committed Mar 22, 2021
    Configuration menu
    Copy the full SHA
    651e380 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    66dba08 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    ef10a3e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    481245c View commit details
    Browse the repository at this point in the history
  6. Fix make_order_by_deterministic for SQLAlchemy 1.4

    Fix errors:
    
    ```
        def make_order_by_deterministic(query):
            """
    
            order_by_func = sa.asc
    
    >       if not query._order_by:
    E       AttributeError: 'Query' object has no attribute '_order_by'
    
    ```
    
    ```
    tests/functions/test_make_order_by_deterministic.py:74:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    query = <sqlalchemy.orm.query.Query object at 0x7f03d5af64f0>
    
        def make_order_by_deterministic(query):
    
                    else:
                        order_by_func = sa.asc
    >               column = order_by.get_children()[0]
    E               TypeError: 'itertools.chain' object is not subscriptable
    ```
    nsoranzo committed Mar 22, 2021
    Configuration menu
    Copy the full SHA
    7c6ebfe View commit details
    Browse the repository at this point in the history
  7. Add message to assert

    nsoranzo committed Mar 22, 2021
    Configuration menu
    Copy the full SHA
    2563593 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    ebf0c32 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    dd720c0 View commit details
    Browse the repository at this point in the history

Commits on Mar 30, 2021

  1. Fix wrong dialect_name check

    Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
    BradenM and nsoranzo authored Mar 30, 2021
    Configuration menu
    Copy the full SHA
    c02fed4 View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2021

  1. Configuration menu
    Copy the full SHA
    c76256c View commit details
    Browse the repository at this point in the history

Commits on Apr 9, 2021

  1. Drop unnecessary alias() call

    This returns a `Subquery` object which is not executable in SQLAlchemy 1.4:
    
    ```
    tests/relationships/test_select_correlated_expression.py:399:
        assert session.execute(aggregate)
    .venv/lib/python3.8/site-packages/sqlalchemy/orm/session.py:1587: in execute
        statement = coercions.expect(roles.StatementRole, statement)
    .venv/lib/python3.8/site-packages/sqlalchemy/sql/coercions.py:200: in expect
        return impl._implicit_coercions(
    .venv/lib/python3.8/site-packages/sqlalchemy/sql/coercions.py:836: in _implicit_coercions
        return super(StatementImpl, self)._implicit_coercions(
    .venv/lib/python3.8/site-packages/sqlalchemy/sql/coercions.py:242: in _implicit_coercions
        self._raise_for_expected(element, argname, resolved)
    .venv/lib/python3.8/site-packages/sqlalchemy/sql/coercions.py:270: in _raise_for_expected
        util.raise_(exc.ArgumentError(msg, code=code), replace_context=err)
    
    E           sqlalchemy.exc.ArgumentError: Executable SQL or text() construct expected, got <sqlalchemy.sql.selectable.Subquery at 0x7fb34b5e1880; test>.
    ```
    nsoranzo committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    99c1324 View commit details
    Browse the repository at this point in the history
  2. fix get_columns tests

    kvesteri committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    7e2a03a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c1dda36 View commit details
    Browse the repository at this point in the history
  4. remove sort_query and get_query_entities

    The sort_query and get_query_entities functions never worked fully as intended and
    contained lots of quirky  edge cases:
    
    1. sort_query function was dangerous in a sense that it could be used for really
    inefficient queries (sorting by non-indexed column).
    2. The entity string label introspection in both functions relied on SQLAlchemy internals
    which were drastically changed in SA 1.4. Relying on those was never a good idea in
    the first place.
    kvesteri committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    460e1da View commit details
    Browse the repository at this point in the history
  5. Remove also get_query_entity_by_alias()

    which depends on `get_query_entities()` which was removed in commit
    460e1da .
    nsoranzo committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    3807a2c View commit details
    Browse the repository at this point in the history
  6. Fix linting errors

    nsoranzo committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    8587bcb View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    a51367b View commit details
    Browse the repository at this point in the history
  8. Update sqlalchemy_utils/compat.py

    Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
    kvesteri and nsoranzo authored Apr 9, 2021
    Configuration menu
    Copy the full SHA
    f62ce80 View commit details
    Browse the repository at this point in the history
  9. fix selectable columns warning

    kvesteri authored and nsoranzo committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    f0020cf View commit details
    Browse the repository at this point in the history
  10. Add health checks for SQL Server docker service

    Remove `!` from password so `SA_PASSWORD` doesn't need extra quotes.
    nsoranzo committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    2a3de7b View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    2b95760 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    8d576ee View commit details
    Browse the repository at this point in the history
  13. Restore engine.dispose()

    nsoranzo committed Apr 9, 2021
    Configuration menu
    Copy the full SHA
    2683f8a View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    c57f6dd View commit details
    Browse the repository at this point in the history

Commits on Apr 11, 2021

  1. change tests to use non-deprecated class

    Change EncryptedType tests to use StringEncryptedType
    kvesteri committed Apr 11, 2021
    Configuration menu
    Copy the full SHA
    f46a7a8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0b28d00 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    823b1dc View commit details
    Browse the repository at this point in the history
  4. isort linting fixes

    nsoranzo committed Apr 11, 2021
    Configuration menu
    Copy the full SHA
    12d88d7 View commit details
    Browse the repository at this point in the history