Nicolas CANIART [Sun, 13 Mar 2022 16:39:40 +0000 (12:39 -0400)]
Fix duplicated constraints when using expressions
Fixed issue where using :meth:`.Operations.create_table` in conjunction
with a :class:`.CheckConstraint` that referred to table-bound
:class:`.Column` objects rather than string expressions would be added to
the parent table twice, resulting in an incorrect DDL sequence. Pull
request courtesy Nicolas CANIART.
Mike Bayer [Wed, 2 Mar 2022 01:56:46 +0000 (20:56 -0500)]
desensitize Oracle to FLOAT/DOUBLE/DOUBLE_PRECISION differences
Oracle Float will come back as DOUBLE_PRECISION
as a result of https://github.com/sqlalchemy/sqlalchemy/issues/5465.
Add some synonyms to prevent changes between these names from resulting
in autogenerate positives.
Mike Bayer [Tue, 15 Feb 2022 14:18:50 +0000 (09:18 -0500)]
repair sharing example
the note re: "we dont have to guess" is wrong.
engine_from_config() returns an engine. It seems
like this example was edited a few times and
was not completely checked (it was me, for sure).
for now just use two separate blocks to eliminate
any problems
Gord Thompson [Thu, 13 Jan 2022 18:46:46 +0000 (11:46 -0700)]
Prevent alter_column() from changing nullability
Fixed bug where an alter_column() operation would change a "NOT NULL"
column to "NULL" by emitting an ALTER COLUMN statement that did not specify
"NOT NULL". (In the absence of "NOT NULL" T-SQL was implicitly assuming
"NULL"). An alter_column() operation that specifies `type_=` should also
specify either `nullable=` or `existing_nullable=` to inform Alembic as to
whether the emitted DDL should include "NULL" or "NOT NULL"; a warning is
now emitted if this is missing under this scenario.
Mike Bayer [Fri, 4 Feb 2022 16:51:30 +0000 (11:51 -0500)]
clarify default configuration behavior
alembic does not by default read other sections
besides ``[alembic]``, however the generated ``env.py``
file by default contains instructions to also read logging
directives. clarify that if the configuration file is
customized to not have logging directives, env.py also
needs to be customized.
Mike Bayer [Tue, 1 Feb 2022 14:12:17 +0000 (09:12 -0500)]
resolve for variant before testing for schema type
Fixed regression where usage of a ``with_variant()`` datatype in
conjunction with the ``existing_type`` option of ``op.alter_column()``
under batch mode would lead to an internal exception.
note this exception would only occur under 1.x, under 2.0
the new variant architecture would have prevented this problem,
however it is best here that the ultimate variant type is
unwrapped in the case that we have a plain type with a
schema type as a variant.
Kai Mueller [Wed, 10 Nov 2021 16:38:11 +0000 (11:38 -0500)]
Add new ensure_version command
Add a new command ``alembic ensure_version``, which will ensure that the
Alembic version table is present in the target database, but does not
alter its contents. Pull request courtesy Kai Mueller.
Mike Bayer [Tue, 16 Nov 2021 19:10:58 +0000 (14:10 -0500)]
support 2.0 style variants
Implemented support for recognizing and rendering SQLAlchemy "variant"
types going forward into SQLAlchemy 2.0, where the architecture of
"variant" datatypes will be changing.
Specifically any TypeEngine can now have "variants" by looking
in the _variant_mapping dictionary collection associated with the
type directly.
Mike Bayer [Sat, 13 Nov 2021 15:27:30 +0000 (10:27 -0500)]
add type synonym for mysql.LONGTEXT / JSON
Added a rule to the MySQL impl so that the translation between JSON /
LONGTEXT is accommodated by autogenerate, treating LONGTEXT from the server
as equivalent to an existing JSON in the model.
Mike Bayer [Fri, 5 Nov 2021 15:24:23 +0000 (11:24 -0400)]
sqlalchemy 2.0 test updates
- disable branched connection tests for 2.x
- dont use future flag for 2.x
- adjust batch tests for autobegin, inconsistent
SQLite transactional DDL behaviors
Gord Thompson [Sat, 23 Oct 2021 17:24:40 +0000 (11:24 -0600)]
Remove code to force ENABLE_ASYNCIO to False
Forcing ENABLE_ASYNCIO to False was interfering
with testing under async drivers when the
(third-party dialect) test suite included both
SQLAlchemy and Alembic tests.
Mike Bayer [Sat, 23 Oct 2021 19:58:37 +0000 (15:58 -0400)]
ensure connection is not None
the inspect() API changed in
https://github.com/sqlalchemy/sqlalchemy2-stubs/commit/68f8417888456588714fcced1c6799f3eb00ff2d
to be more accurate which correctly appears to necessitate a
type check in Alembic AutogenContext.inspector() to ensure
"self.connection" isn't None
Fixed type annotations for the "constraint_name" argument of operations
``create_primary_key()``, ``create_foreign_key()``. Pull request courtesy
TilmanK.
Mike Bayer [Wed, 15 Sep 2021 20:43:45 +0000 (16:43 -0400)]
render 3rd party module annotations as forward references
Fixed issue where registration of custom ops was prone to failure due to
the registration process running ``exec()`` on generated code that as of
the 1.7 series includes pep-484 annotations, which in the case of end user
code would result in name resolution errors when the exec occurs. The logic
in question has been altered so that the annotations are rendered as
forward references so that the ``exec()`` can proceed.
Adds exception when trying to run write_pyi.py with Python < 3.9
### Description
write_pyi.py now raises an exception when someone tries to run the script with Python version 3.8 or smaller.
This also fixes:
- When using absolute Paths, i.e. on Windows, they are now converted to relative paths to avoid useless changes in the doc strings of the pyi files
- Corrected destination_path argument type when calling `generate_pyi_for_proxy` in `run_file`
- A comment typo
Mike Bayer [Mon, 30 Aug 2021 20:02:02 +0000 (16:02 -0400)]
check all directives in batch block until recreate selected
Fixed regression in batch mode due to :ticket:`883` where the "auto" mode
of batch would fail to accommodate any additional migration directives
beyond encountering an ``add_column()`` directive, due to a mis-application
of the conditional logic that was added as part of this change, leading to
"recreate" mode not being used in cases where it is required for SQLite
such as for unique constraints.
layday [Mon, 30 Aug 2021 17:30:05 +0000 (13:30 -0400)]
Do not tag wheel as being compatible with Python 2
Corrected "universal wheel" directive in setup.cfg so that building a wheel
does not target Python 2. The PyPi files index for 1.7.0 was corrected
manually. Pull request courtesy layday.
Mike Bayer [Thu, 26 Aug 2021 22:25:29 +0000 (18:25 -0400)]
decouple pyproject.toml from the test suite
tools/write_pyi.py is run as part of the test suite,
which has to run from a source distribution, which
does not have pyproject.toml right now due to
issues reported w/ pip. these pip issues are probably
resolved now however we have not gone back to including
pyproject.toml at the moment. so we therefore have to
hardcode the single "-l79" black config option in
write_pyi.py.
Mike Bayer [Mon, 23 Aug 2021 17:31:57 +0000 (13:31 -0400)]
support named CHECK constraints in batch
Named CHECK constraints are now supported by batch mode, and will
automatically be part of the recreated table assuming they are named. They
also can be explicitly dropped using ``op.drop_constraint()``. For
"unnamed" CHECK constraints, these are still skipped as they cannot be
distinguished from the CHECK constraints that are generated by the
``Boolean`` and ``Enum`` datatypes.
Note that this change may require adjustments to migrations that drop or
rename columns which feature an associated named check constraint, such
that an additional ``op.drop_constraint()`` directive should be added for
that named constraint as there will no longer be an associated column
for it; for the ``Boolean`` and ``Enum`` datatypes, an ``existing_type``
keyword may be passed to ``BatchOperations.drop_constraint`` as well.
Mike Bayer [Mon, 23 Aug 2021 20:24:26 +0000 (16:24 -0400)]
remove dependency on pkg_resources
The dependency on ``pkg_resources`` which is part of ``setuptools`` has
been removed, so there is no longer any runtime dependency on
``setuptools``. The functionality has been replaced with
``importlib.metadata`` and ``importlib.resources`` which are both part of
Python std.lib, or via pypy dependency ``importlib-metadata`` for Python
version < 3.8 and ``importlib-resources`` for Python version < 3.7.