Mike Bayer [Wed, 3 Jul 2019 17:38:48 +0000 (13:38 -0400)]
Add cookbook recipe for non-ascii migration files under python 2
Unicode-related directives can be added to ``script.py.mako``
and as this issue has never been reported for many years as well
as that Python 2 is deprecated, resolve this as a cookbook recipe
that illustrates where unicode related directives and conversions
need to occur under Python 2.
Mike Bayer [Tue, 25 Jun 2019 15:40:56 +0000 (11:40 -0400)]
Ensure SQLite default expressions are parenthesized
- SQLite server default reflection will ensure parenthesis are surrounding a
column default expression that is detected as being a non-constant
expression, such as a ``datetime()`` default, to accommodate for the
requirement that SQL expressions have to be parenthesized when being sent
as DDL. Parenthesis are not added to constant expressions to allow for
maximum cross-compatibility with other dialects and existing test suites
(such as Alembic's), which necessarily entails scanning the expression to
eliminate for constant numeric and string values. The logic is added to the
two "reflection->DDL round trip" paths which are currently autogenerate and
batch migration. Within autogenerate, the logic is on the rendering side,
whereas in batch the logic is installed as a column reflection hook.
- Improved SQLite server default comparison to accommodate for a ``text()``
construct that added parenthesis directly vs. a construct that relied
upon the SQLAlchemy SQLite dialect to render the parenthesis, as well
as improved support for various forms of constant expressions such as
values that are quoted vs. non-quoted.
- Fixed bug where the "literal_binds" flag was not being set when
autogenerate would create a server default value, meaning server default
comparisons would fail for functions that contained literal values.
Report warnings from caller's file/line number, not utils.py
Warnings emitted by Alembic now include a default stack level of 2, and in
some cases it's set to 3, in order to help warnings indicate more closely
where they are originating from. Pull request courtesy Ash Berlin-Taylor.
Mike Bayer [Mon, 3 Jun 2019 16:52:12 +0000 (12:52 -0400)]
Add "usecase" changelog tag
"usecase" indicates the library now supports something a user
was trying to do. It's not quite a "feature" since it's something
that seems like it should have worked, it's not a "bug" because
no mistake was made, it's just something that wasn't considered before.
The advantage of "usecase" is that it inherently suggests a different
style of prioritization vs. something that is preventing the library
from working as designed.
This change also adds docs/build/conf.py under the pep8 formatting
test coverage, and additionally moves release / release_date to
be present within; the release scripts will be altered to include
this.
Mike Bayer [Wed, 29 May 2019 21:32:57 +0000 (17:32 -0400)]
Use vendored getargspec()
Replaced the Python compatbility routines for ``getargspec()`` with a fully
vendored version based on ``getfullargspec()`` from Python 3.3.
Originally, Python was emitting deprecation warnings for this function in
Python 3.8 alphas. While this change was reverted, it was observed that
Python 3 implementations for ``getfullargspec()`` are an order of magnitude
slower as of the 3.4 series where it was rewritten against ``Signature``.
While Python plans to improve upon this situation, SQLAlchemy projects for
now are using a simple replacement to avoid any future issues.
Mike Bayer [Mon, 20 May 2019 17:29:55 +0000 (13:29 -0400)]
Use CHANGE COLUMN for MySQL / MariaDB DateTime server default change
Fixed issue where MySQL databases need to use CHANGE COLUMN when altering a
server default of CURRENT_TIMESTAMP, NOW() and probably other functions
that are only usable with DATETIME/TIMESTAMP columns. While MariaDB
supports both CHANGE and ALTER COLUMN in this case, MySQL databases only
support CHANGE. So the new logic is that if the server default change is
against a DateTime-oriented column, the CHANGE format is used
unconditionally, as in the vast majority of cases the server default is to
be CURRENT_TIMESTAMP which may also be potentially bundled with an "ON
UPDATE CURRENT_TIMESTAMP" directive, which SQLAlchemy does not currently
support as a distinct field.
Mike Bayer [Sun, 19 May 2019 22:33:39 +0000 (18:33 -0400)]
Create alter column backend test fixture
For more expedient confirmation of op functionality,
start building generalized backend fixtures for ops.
Add basic round trip tests for alter column, obviously
disabled on SQLite. Ensure this passes for the full
span of MySQL, Oracle, SQL Server on CI (PG is fine).
Next we can begin adding tests for all the MySQL issues
that are coming up such as #564, where regular ALTER COLUMN
is not consistently implemented based on datatypes etc.
Mike Bayer [Tue, 30 Apr 2019 14:23:20 +0000 (10:23 -0400)]
Emit DROP CHECK for MySQL, DROP CONSTRAINT for MariaDB
Added support for MySQL "DROP CHECK", which is added as of MySQL 8.0.16,
separate from MariaDB's "DROP CONSTRAINT" for CHECK constraints. The MySQL
Alembic implementation now checks for "MariaDB" in server_version_info to
decide which one to use.
Mike Bayer [Sat, 27 Apr 2019 00:22:21 +0000 (20:22 -0400)]
Check for rendered integer default is None on MySQL
Fixed bug when using the
:paramref:`.EnvironmentContext.configure.compare_server_default` flag set
to ``True``where a server default that is introduced in the table metadata
on an ``Integer`` column, where there is no existing server default in the
database, would raise a ``TypeError``.
Mike Bayer [Wed, 24 Apr 2019 18:46:03 +0000 (13:46 -0500)]
Raise for non-string revision identifier
Added an assertion in :meth:`.RevisionMap.get_revisions` and other methods
which ensures revision numbers are passed as strings or collections of
strings. Driver issues particularly on MySQL may inadvertently be passing
bytes here which leads to failures later on.
Mike Bayer [Tue, 23 Apr 2019 17:21:09 +0000 (12:21 -0500)]
Use first line of command docstring for help text.
Fixed bug introduced in release 1.0.9 where the helptext for commands
inadvertently got expanded to include function docstrings from the
command.py module. The logic has been adjusted to only refer to the first
line of each docstring as was the original intent.
Mike Bayer [Fri, 29 Mar 2019 17:46:32 +0000 (13:46 -0400)]
Remove formatargspec work from create_method_proxy
Simplified the internal scheme used to generate the ``alembic.op`` namespace
to no longer attempt to generate full method signatures (e.g. rather than
generic ``*args, **kw``) as this was not working in most cases anyway, while
in rare circumstances it would in fact sporadically have access to the real
argument names and then fail when generating the function due to missing
symbols in the argument signature.
Mike Bayer [Mon, 4 Mar 2019 14:37:08 +0000 (09:37 -0500)]
Clarify and correct PostgreSQL server default comparison for py37
Fixed issue where server default comparison on the PostgreSQL dialect would
fail for a blank string on Python 3.7 only, due to a change in regular
expression behavior in Python 3.7.
Parth Shandilya [Mon, 4 Feb 2019 19:26:48 +0000 (14:26 -0500)]
Removed force parameter from base.py
Removed use of deprecated ``force`` parameter for SQLAlchemy quoting
functions as this parameter will be removed in a future release.
Pull request courtesy Parth Shandilya(ParthS007).
Mike Bayer [Thu, 7 Feb 2019 15:04:41 +0000 (10:04 -0500)]
Repair tests for SQLAlchemy 1.3 safestring change
Latest 1.3 includes checks for valid SQL keywords and applies
column() to the element of ExcludeConstraint, adjust tests to
work for this as well as previous behavior.
Damien Garaud [Wed, 23 Jan 2019 16:13:37 +0000 (11:13 -0500)]
Fix single quote escaping for the SQL comments
Fixed issue in new comment support where autogenerated Python code
for comments wasn't using ``repr()`` thus causing issues with
quoting. Pull request courtesy Damien Garaud.
Mike Bayer [Fri, 11 Jan 2019 20:40:10 +0000 (15:40 -0500)]
Update comment documentation, make sure tests always run
Corrected the links and text in the changelog note as well as
ensured new comment-oriented methods and parameters include a
versionadded token. Added a more specific check so that
any run of the tests will make sure SQLAlchemy issue 4436
is resolved as 1.2.16 resolves it but 1.3.0b1, which currently
comes out for "python setup.py test", does not.
Mike Waites [Fri, 31 Aug 2018 18:56:36 +0000 (19:56 +0100)]
Implemented support for Table and Column Comments
Added Table and Column level comments for supported backends.
`create_table`, `add_column` and `alter_column` now optionally
take `comment="X"` kwarg. Support for autogenerate for Table
and Column objects has also been added
Mike Bayer [Fri, 28 Dec 2018 14:05:27 +0000 (09:05 -0500)]
reword op.execute()
Apparently op.execute() makes use of _exec() which coerces strings
into text() constructs. This is less than ideal, however for now
document the caveat that colons need to be escaped.
Stefan Tjarks [Thu, 22 Nov 2018 03:08:56 +0000 (22:08 -0500)]
Vendor python3 formatargspec, import from collections.abc
Resolved remaining Python 3 deprecation warnings, covering
the use of inspect.formatargspec() with a vendored version
copied from the Python standard library, importing
collections.abc above Python 3.3 when testing against abstract
base classes, fixed one occurrence of log.warn(), as well as a few
invalid escape sequences.
Add DeprecationWarning to the test suite as an error raise
as has been the case within SQLAlchemy for some time now.
Fixes: #507 Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I121121b3d2dd90e6f3c9b16dec2fc80b9699c400
Pull-request: https://bitbucket.org/zzzeek/alembic/pull-requests/85
Mike Bayer [Wed, 14 Nov 2018 18:53:57 +0000 (13:53 -0500)]
Check for mssql_include is None
Fixed regression caused by :ticket:`513`, where the logic to consume
``mssql_include`` was not correctly interpreting the case where the flag
was not present, breaking the ``op.create_index`` directive for SQL Server
as a whole.
Mike Bayer [Wed, 24 Oct 2018 17:44:09 +0000 (13:44 -0400)]
Dont autogenerate "system=True", render flag correctly
The ``system=True`` flag on :class:`.Column`, used primarily in conjunction
with the Postgresql "xmin" column, now renders within the autogenerate
render process, allowing the column to be excluded from DDL. Additionally,
adding a system=True column to a model will produce no autogenerate diff as
this column is implicitly present in the database.
Mike Bayer [Fri, 19 Oct 2018 14:00:50 +0000 (10:00 -0400)]
Add special handling for SQL Server create_index mssql_includes
Fixed issue where usage of the SQL Server ``mssql_include`` option within a
:meth:`.Operations.create_index` would raise a KeyError, as the additional
column(s) need to be added to the table object used by the construct
internally.
Mike Bayer [Wed, 17 Oct 2018 14:14:22 +0000 (10:14 -0400)]
Replace union_update with update
Fixed issue where removed method ``union_update()`` was used when a
customized :class:`.MigrationScript` instance included entries in the
``.imports`` data member, raising an AttributeError.
Mike Bayer [Wed, 17 Oct 2018 14:09:50 +0000 (10:09 -0400)]
Revert "Replace set union_update() references with update()"
This reverts commit 7e3d032cc92af73988f02f281ab354de7fc8e3ab. the
PR was not provided with a test case or bug report and this is actually
an uncovered code bug. will re-submit with a proper bug report
Luis Calderon [Tue, 16 Oct 2018 13:38:54 +0000 (09:38 -0400)]
Replace set union_update() references with update()
The autogenerate api references the `union_update()` method of sets which was removed in Python 2.4. The previous method is actually an alias for the `update()` method.
This PR replaces the api reference with the correct one for Python 2.7
Mike Waites [Fri, 31 Aug 2018 19:42:27 +0000 (19:42 +0000)]
Don't format output twice in writer
Fixed an issue where revision descriptions were essentially
being formatted twice. Any revision description that contained
characters like %, writing output to stdout will fail because
the call to config.print_stdout attempted to format any
additional args passed to the function.
This fix now only applies string formatting if any args are provided
along with the output text.
Mike Bayer [Fri, 31 Aug 2018 20:24:16 +0000 (16:24 -0400)]
Run batch tests per backend
Seeing a new unexpected success in limited scope for mysql,
correlating with addition of mariadb 10.3 to CI. This test
should be producing db-specific successes/failures to track
it more easily