from ..util import sqla_compat
from ..util.sqla_compat import create_mock_engine
from ..util.sqla_compat import sqla_14
-from ..util.sqla_compat import sqla_1x
+from ..util.sqla_compat import sqla_2
testing_config = configparser.ConfigParser()
class TestBase(SQLAlchemyTestBase):
- if sqla_1x:
- is_sqlalchemy_future = False
- else:
- is_sqlalchemy_future = True
+ is_sqlalchemy_future = sqla_2
@testing.fixture()
def ops_context(self, migration_context):
@property
def sqlalchemy_1x(self):
return exclusions.skip_if(
- lambda config: not util.sqla_1x,
+ lambda config: util.sqla_2,
"SQLAlchemy 1.x test",
)
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from __future__ import annotations
-import re
import types
from typing import Union
from sqlalchemy.util import inspect_getfullargspec
+from ..util import sqla_2
+
def flag_combinations(*combinations):
"""A facade around @testing.combinations() oriented towards boolean
def testing_engine(url=None, options=None, future=False):
from sqlalchemy.testing import config
from sqlalchemy.testing.engines import testing_engine
- from sqlalchemy import __version__
-
- _vers = tuple(
- [_safe_int(x) for x in re.findall(r"(\d+|[abc]\d)", __version__)]
- )
- sqla_1x = _vers < (2,)
if not future:
future = getattr(config._current.options, "future_engine", False)
- if sqla_1x:
+ if not sqla_2:
kw = {"future": future} if future else {}
else:
kw = {}
from .sqla_compat import has_computed
from .sqla_compat import sqla_13
from .sqla_compat import sqla_14
-from .sqla_compat import sqla_1x
from .sqla_compat import sqla_2
from sqlalchemy.sql.elements import _NONE_NAME as _NONE_NAME # type: ignore # noqa: E501
-if sqla_14:
- # when future engine merges, this can be again based on version string
- from sqlalchemy.engine import Connection as legacy_connection
+class _Unsupported:
+ "Placeholder for unsupported SQLAlchemy classes"
- sqla_1x = not hasattr(legacy_connection, "commit")
-else:
- sqla_1x = True
try:
- from sqlalchemy import Computed # noqa
+ from sqlalchemy import Computed
except ImportError:
- Computed = type(None) # type: ignore
+
+ class Computed(_Unsupported): # type: ignore
+ pass
+
has_computed = False
has_computed_reflection = False
else:
has_computed_reflection = _vers >= (1, 3, 16)
try:
- from sqlalchemy import Identity # noqa
+ from sqlalchemy import Identity
except ImportError:
- Identity = type(None) # type: ignore
+
+ class Identity(_Unsupported): # type: ignore
+ pass
+
has_identity = False
else:
- # attributes common to Indentity and Sequence
+ # attributes common to Identity and Sequence
_identity_options_attrs = (
"start",
"increment",
"cache",
"order",
)
- # attributes of Indentity
+ # attributes of Identity
_identity_attrs = _identity_options_attrs + ("on_null",)
has_identity = True
.. change::
:tags: usecase, commands
+ :tickets: 1109
Added quiet option to the command line, using the ``-q/--quiet``
option. This flag will prevent alembic from logging anything
--- /dev/null
+.. change::
+ :tags: bug, batch
+ :tickets: 1237
+
+ Added placeholder classes for ``Computed`` and ``Identity`` when older 1.x
+ SQLAlchemy versions are in use, namely prior to SQLAlchemy 1.3.11 when the
+ ``Computed`` construct was introduced. Previously these were set to None,
+ however this could cause issues with certain codepaths that were using
+ ``isinstance()`` such as one within "batch mode".