Hello community,

here is the log from the commit of package python-SQLAlchemy-Utils for 
openSUSE:Factory checked in at 2020-01-02 14:43:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-SQLAlchemy-Utils (Old)
 and      /work/SRC/openSUSE:Factory/.python-SQLAlchemy-Utils.new.6675 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-SQLAlchemy-Utils"

Thu Jan  2 14:43:22 2020 rev:23 rq:760370 version:0.36.1

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-SQLAlchemy-Utils/python-SQLAlchemy-Utils.changes
  2019-12-13 12:05:10.413384052 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-SQLAlchemy-Utils.new.6675/python-SQLAlchemy-Utils.changes
        2020-01-02 14:43:39.528966744 +0100
@@ -1,0 +2,8 @@
+Sun Dec 29 21:12:16 UTC 2019 - Arun Persaud <[email protected]>
+
+- update to version 0.36.1:
+  * Added support for CASCADE option when dropping views (#406, pull
+    request courtesy of amicks)
+  * Added aliases parameter to create_materialized_view function.
+
+-------------------------------------------------------------------

Old:
----
  SQLAlchemy-Utils-0.36.0.tar.gz

New:
----
  SQLAlchemy-Utils-0.36.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-SQLAlchemy-Utils.spec ++++++
--- /var/tmp/diff_new_pack.bAw0TW/_old  2020-01-02 14:43:40.252967030 +0100
+++ /var/tmp/diff_new_pack.bAw0TW/_new  2020-01-02 14:43:40.256967031 +0100
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-SQLAlchemy-Utils
-Version:        0.36.0
+Version:        0.36.1
 Release:        0
 Summary:        Various utility functions for SQLAlchemy
 License:        BSD-3-Clause

++++++ SQLAlchemy-Utils-0.36.0.tar.gz -> SQLAlchemy-Utils-0.36.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.36.0/CHANGES.rst 
new/SQLAlchemy-Utils-0.36.1/CHANGES.rst
--- old/SQLAlchemy-Utils-0.36.0/CHANGES.rst     2019-12-08 18:38:14.000000000 
+0100
+++ new/SQLAlchemy-Utils-0.36.1/CHANGES.rst     2019-12-23 09:48:35.000000000 
+0100
@@ -4,6 +4,13 @@
 Here you can see the full list of changes between each SQLAlchemy-Utils 
release.
 
 
+0.36.1 (2019-12-23)
+^^^^^^^^^^^^^^^^^^^
+
+- Added support for CASCADE option when dropping views (#406, pull request 
courtesy of amicks)
+- Added `aliases` parameter to create_materialized_view function.
+
+
 0.36.0 (2019-12-08)
 ^^^^^^^^^^^^^^^^^^^
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.36.0/PKG-INFO 
new/SQLAlchemy-Utils-0.36.1/PKG-INFO
--- old/SQLAlchemy-Utils-0.36.0/PKG-INFO        2019-12-08 18:38:54.000000000 
+0100
+++ new/SQLAlchemy-Utils-0.36.1/PKG-INFO        2019-12-23 09:54:52.000000000 
+0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: SQLAlchemy-Utils
-Version: 0.36.0
+Version: 0.36.1
 Summary: Various utility functions for SQLAlchemy.
 Home-page: https://github.com/kvesteri/sqlalchemy-utils
 Author: Konsta Vesterinen, Ryan Leckey, Janne Vanhala, Vesa Uimonen
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/SQLAlchemy-Utils-0.36.0/SQLAlchemy_Utils.egg-info/PKG-INFO 
new/SQLAlchemy-Utils-0.36.1/SQLAlchemy_Utils.egg-info/PKG-INFO
--- old/SQLAlchemy-Utils-0.36.0/SQLAlchemy_Utils.egg-info/PKG-INFO      
2019-12-08 18:38:54.000000000 +0100
+++ new/SQLAlchemy-Utils-0.36.1/SQLAlchemy_Utils.egg-info/PKG-INFO      
2019-12-23 09:54:51.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: SQLAlchemy-Utils
-Version: 0.36.0
+Version: 0.36.1
 Summary: Various utility functions for SQLAlchemy.
 Home-page: https://github.com/kvesteri/sqlalchemy-utils
 Author: Konsta Vesterinen, Ryan Leckey, Janne Vanhala, Vesa Uimonen
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.36.0/sqlalchemy_utils/__init__.py 
new/SQLAlchemy-Utils-0.36.1/sqlalchemy_utils/__init__.py
--- old/SQLAlchemy-Utils-0.36.0/sqlalchemy_utils/__init__.py    2019-12-08 
18:38:14.000000000 +0100
+++ new/SQLAlchemy-Utils-0.36.1/sqlalchemy_utils/__init__.py    2019-12-23 
09:48:02.000000000 +0100
@@ -100,4 +100,4 @@
     refresh_materialized_view
 )
 
-__version__ = '0.36.0'
+__version__ = '0.36.1'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.36.0/sqlalchemy_utils/view.py 
new/SQLAlchemy-Utils-0.36.1/sqlalchemy_utils/view.py
--- old/SQLAlchemy-Utils-0.36.0/sqlalchemy_utils/view.py        2019-04-22 
10:53:34.000000000 +0200
+++ new/SQLAlchemy-Utils-0.36.1/sqlalchemy_utils/view.py        2019-12-23 
09:48:02.000000000 +0100
@@ -20,16 +20,18 @@
 
 
 class DropView(DDLElement):
-    def __init__(self, name, materialized=False):
+    def __init__(self, name, materialized=False, cascade=True):
         self.name = name
         self.materialized = materialized
+        self.cascade = cascade
 
 
 @compiler.compiles(DropView)
 def compile_drop_materialized_view(element, compiler, **kw):
-    return 'DROP {}VIEW IF EXISTS {} CASCADE'.format(
+    return 'DROP {}VIEW IF EXISTS {} {}'.format(
         'MATERIALIZED ' if element.materialized else '',
-        element.name
+        element.name,
+        'CASCADE' if element.cascade else ''
     )
 
 
@@ -37,14 +39,22 @@
     name,
     selectable,
     indexes=None,
-    metadata=None
+    metadata=None,
+    aliases=None
 ):
     if indexes is None:
         indexes = []
     if metadata is None:
         metadata = sa.MetaData()
+    if aliases is None:
+        aliases = {}
     args = [
-        sa.Column(c.name, c.type, primary_key=c.primary_key)
+        sa.Column(
+            c.name,
+            c.type,
+            key=aliases.get(c.name, c.name),
+            primary_key=c.primary_key
+        )
         for c in selectable.c
     ] + indexes
     table = sa.Table(name, metadata, *args)
@@ -60,7 +70,8 @@
     name,
     selectable,
     metadata,
-    indexes=None
+    indexes=None,
+    aliases=None
 ):
     """ Create a view on a given metadata
 
@@ -70,6 +81,9 @@
         An SQLAlchemy Metadata instance that stores the features of the
         database being described.
     :param indexes: An optional list of SQLAlchemy Index instances.
+    :param aliases:
+        An optional dictionary containing with keys as column names and values
+        as column aliases.
 
     Same as for ``create_view`` except that a ``CREATE MATERIALIZED VIEW``
     statement is emitted instead of a ``CREATE VIEW``.
@@ -79,7 +93,8 @@
         name=name,
         selectable=selectable,
         indexes=indexes,
-        metadata=None
+        metadata=None,
+        aliases=aliases
     )
 
     sa.event.listen(
@@ -104,7 +119,8 @@
 def create_view(
     name,
     selectable,
-    metadata
+    metadata,
+    cascade_on_drop=True
 ):
     """ Create a view on a given metadata
 
@@ -149,7 +165,11 @@
         for idx in table.indexes:
             idx.create(connection)
 
-    sa.event.listen(metadata, 'before_drop', DropView(name))
+    sa.event.listen(
+        metadata,
+        'before_drop',
+        DropView(name, cascade=cascade_on_drop)
+    )
     return table
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/SQLAlchemy-Utils-0.36.0/tests/test_views.py 
new/SQLAlchemy-Utils-0.36.1/tests/test_views.py
--- old/SQLAlchemy-Utils-0.36.0/tests/test_views.py     2018-10-14 
09:07:28.000000000 +0200
+++ new/SQLAlchemy-Utils-0.36.1/tests/test_views.py     2019-12-23 
09:48:02.000000000 +0100
@@ -45,6 +45,7 @@
                     .join(User, Article.author_id == User.id)
                 )
             ),
+            aliases={'name': 'article_name'},
             metadata=Base.metadata,
             indexes=[sa.Index('article_mv_id_idx', 'id')]
         )
@@ -95,7 +96,7 @@
         session.commit()
         refresh_materialized_view(session, 'article_mv')
         materialized = session.query(ArticleMV).first()
-        assert materialized.name == 'Some article'
+        assert materialized.article_name == 'Some article'
         assert materialized.author_name == 'Some user'
 
     def test_querying_view(
@@ -114,3 +115,67 @@
         row = session.query(ArticleView).first()
         assert row.name == 'Some article'
         assert row.author_name == 'Some user'
+
+
+class TrivialViewTestCases:
+    def life_cycle(
+        self,
+        engine,
+        metadata,
+        column,
+        cascade_on_drop
+    ):
+        __table__ = create_view(
+            name='trivial_view',
+            selectable=sa.select([column]),
+            metadata=metadata,
+            cascade_on_drop=cascade_on_drop
+        )
+        __table__.create(engine)
+        __table__.drop(engine)
+
+
+class SupportsCascade(TrivialViewTestCases):
+    def test_life_cycle_cascade(
+        self,
+        connection,
+        engine,
+        Base,
+        User
+    ):
+        self.life_cycle(engine, Base.metadata, User.id, cascade_on_drop=True)
+
+
+class DoesntSupportCascade(SupportsCascade):
+    @pytest.mark.xfail
+    def test_life_cycle_cascade(self, *args, **kwargs):
+        super(DoesntSupportCascade, self).test_life_cycle_cascade(
+            *args,
+            **kwargs
+        )
+
+
+class SupportsNoCascade(TrivialViewTestCases):
+    def test_life_cycle_no_cascade(
+        self,
+        connection,
+        engine,
+        Base,
+        User
+    ):
+        self.life_cycle(engine, Base.metadata, User.id, cascade_on_drop=False)
+
+
[email protected]('postgresql_dsn')
+class TestPostgresTrivialView(SupportsCascade, SupportsNoCascade):
+    pass
+
+
[email protected]('mysql_dsn')
+class TestMySqlTrivialView(SupportsCascade, SupportsNoCascade):
+    pass
+
+
[email protected]('sqlite_none_database_dsn')
+class TestSqliteTrivialView(DoesntSupportCascade, SupportsNoCascade):
+    pass


Reply via email to