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

nonexistent union_update() in custom imports rendering, also not tested at all #512

Closed
sqlalchemy-bot opened this Issue Oct 17, 2018 · 3 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Oct 17, 2018

Migrated issue, originally created by Michael Bayer (@zzzeek)

this has been broken for a long time:

diff --git a/tests/test_script_production.py b/tests/test_script_production.py
index 7ab46ab..af01a38 100644
--- a/tests/test_script_production.py
+++ b/tests/test_script_production.py
@@ -605,7 +605,7 @@ class ImportsTest(TestBase):
     def tearDown(self):
         clear_staging_env()
 
-    def _env_fixture(self, target_metadata):
+    def _env_fixture(self, target_metadata, **kw):
         self.engine = engine = _sqlite_file_db()
 
         def run_env(self):
@@ -614,7 +614,8 @@ class ImportsTest(TestBase):
             with engine.connect() as connection:
                 context.configure(
                     connection=connection,
-                    target_metadata=target_metadata)
+                    target_metadata=target_metadata,
+                    **kw)
                 with context.begin_transaction():
                     context.run_migrations()
 
@@ -636,13 +637,22 @@ class ImportsTest(TestBase):
             Column('x', type_)
         )
 
-        with self._env_fixture(m):
+        def process_revision_directives(context, rev, generate_revisions):
+            generate_revisions[0].imports.add(
+                "from sqlalchemy.dialects.mysql import TINYINT")
+
+        with self._env_fixture(
+                m,
+                process_revision_directives=process_revision_directives
+        ):
             rev = command.revision(
                 self.cfg, message="some message",
                 autogenerate=True)
 
         with open(rev.path) as file_:
-            assert "from sqlalchemy.dialects import mysql" in file_.read()
+            contents = file_.read()
+            assert "from sqlalchemy.dialects import mysql" in contents
+            assert "from sqlalchemy.dialects.mysql import TINYINT" in contents
 
 
 class MultiContextTest(TestBase):

see zzzeek/alembic#46 for pr but we have to re-submit

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Oct 17, 2018

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Oct 17, 2018

Michael Bayer (@zzzeek) wrote:

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.

Change-Id: Ia141db106bc3d57238e2fa6a546041fd573c0ea4
Fixes: #512

4848be7

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Oct 17, 2018

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment