diff -pruN 0.41.0-5/CHANGES.rst 0.41.1-0ubuntu1/CHANGES.rst
--- 0.41.0-5/CHANGES.rst	2023-04-13 10:36:30.000000000 +0000
+++ 0.41.1-0ubuntu1/CHANGES.rst	2023-04-27 11:28:21.000000000 +0000
@@ -4,6 +4,13 @@ Changelog
 Here you can see the full list of changes between each SQLAlchemy-Utils release.
 
 
+0.41.1 (2023-04-27)
+^^^^^^^^^^^^^^^^^^^
+
+- Use a custom SQL construct for refreshing materialized views in
+  `refresh_materialized_view` (#703)
+
+
 0.41.0 (2023-04-13)
 ^^^^^^^^^^^^^^^^^^^
 
diff -pruN 0.41.0-5/debian/changelog 0.41.1-0ubuntu1/debian/changelog
--- 0.41.0-5/debian/changelog	2024-12-16 15:07:27.000000000 +0000
+++ 0.41.1-0ubuntu1/debian/changelog	2024-02-09 09:49:02.000000000 +0000
@@ -1,22 +1,18 @@
-python-sqlalchemy-utils (0.41.0-5) unstable; urgency=medium
+python-sqlalchemy-utils (0.41.1-0ubuntu1) noble; urgency=medium
 
-  * Add remove-intersphinx.patch (Closes: #1090161).
+  * New upstream point release.
 
- -- Thomas Goirand <zigo@debian.org>  Mon, 16 Dec 2024 16:07:27 +0100
+ -- James Page <james.page@ubuntu.com>  Fri, 09 Feb 2024 09:49:02 +0000
 
-python-sqlalchemy-utils (0.41.0-4) unstable; urgency=medium
+python-sqlalchemy-utils (0.41.0-2ubuntu1) noble; urgency=medium
 
-  * Removed python3-psycopg2cffi from (build-)depends, as this is optional, and
-    nothing really needs it.
+  * Merge from Debian unstable. Remaining changes:
+    - d/control: Make infinity and psycopg2cffi optional. Add
+      python3-intervals to dependencies (the package doesn't exist
+      in Debian).
+    - d/tests: Add autopkgtests.
 
- -- Thomas Goirand <zigo@debian.org>  Mon, 23 Sep 2024 09:05:25 +0200
-
-python-sqlalchemy-utils (0.41.0-3) unstable; urgency=medium
-
-  * Remove extraneous python3-six & python3-mock dependencies
-    (Closes: #1068098).
-
- -- Thomas Goirand <zigo@debian.org>  Thu, 18 Apr 2024 09:44:32 +0200
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Mon, 04 Dec 2023 16:54:13 -0800
 
 python-sqlalchemy-utils (0.41.0-2) unstable; urgency=medium
 
@@ -37,6 +33,16 @@ python-sqlalchemy-utils (0.38.2-3) unsta
 
  -- Thomas Goirand <zigo@debian.org>  Tue, 15 Aug 2023 16:03:25 +0200
 
+python-sqlalchemy-utils (0.38.2-2ubuntu1) mantic; urgency=low
+
+  * Merge from Debian unstable. Remaining changes:
+    - d/control: Make infinity and psycopg2cffi optional. Add
+      python3-intervals to dependencies (the package doesn't exist
+      in Debian).
+    - d/tests: Add autopkgtests.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Mon, 12 Jun 2023 11:43:11 -0700
+
 python-sqlalchemy-utils (0.38.2-2) unstable; urgency=medium
 
   * Uploading to unstable.
@@ -50,6 +56,16 @@ python-sqlalchemy-utils (0.38.2-1) exper
 
  -- Thomas Goirand <zigo@debian.org>  Wed, 16 Feb 2022 10:47:54 +0100
 
+python-sqlalchemy-utils (0.37.8-1ubuntu1) jammy; urgency=low
+
+  * Merge from Debian unstable. Remaining changes:
+    - d/control: Make infinity and psycopg2cffi optional. Add
+      python3-intervals to dependencies (the package doesn't exist
+      in Debian).
+    - d/tests: Add autopkgtests.
+
+ -- Corey Bryant <corey.bryant@canonical.com>  Fri, 03 Dec 2021 11:17:06 -0500
+
 python-sqlalchemy-utils (0.37.8-1) unstable; urgency=medium
 
   * New upstream release.
@@ -84,6 +100,20 @@ python-sqlalchemy-utils (0.36.8-3) unsta
 
  -- Thomas Goirand <zigo@debian.org>  Fri, 08 Jan 2021 10:17:10 +0100
 
+python-sqlalchemy-utils (0.36.8-2ubuntu2) hirsute; urgency=medium
+
+  * d/control: Make infinity and psycopq2cffi optional.
+
+ -- Chris MacNaughton <chris.macnaughton@ubuntu.com>  Thu, 07 Jan 2021 10:35:22 +0000
+
+python-sqlalchemy-utils (0.36.8-2ubuntu1) hirsute; urgency=medium
+
+  * Merge from Debian unstable. Remaining changes:
+    - Add python3-intervals to dependencies
+      (the package doesn't exist in Debian)
+
+ -- Gianfranco Costamagna <locutusofborg@debian.org>  Thu, 10 Dec 2020 14:28:04 +0100
+
 python-sqlalchemy-utils (0.36.8-2) unstable; urgency=medium
 
   * Added python3-psycopg2cffi and python3-infinity as (build-)depends.
@@ -91,6 +121,14 @@ python-sqlalchemy-utils (0.36.8-2) unsta
 
  -- Thomas Goirand <zigo@debian.org>  Sat, 05 Dec 2020 00:02:16 +0100
 
+python-sqlalchemy-utils (0.36.8-1ubuntu1) hirsute; urgency=low
+
+  * Merge from Debian unstable. Remaining changes:
+    - Add python3-intervals to dependencies
+      (the package doesn't exist in Debian)
+
+ -- Gianfranco Costamagna <locutusofborg@debian.org>  Mon, 23 Nov 2020 22:14:07 +0100
+
 python-sqlalchemy-utils (0.36.8-1) unstable; urgency=medium
 
   * New upstream release.
@@ -98,6 +136,26 @@ python-sqlalchemy-utils (0.36.8-1) unsta
 
  -- Thomas Goirand <zigo@debian.org>  Sun, 22 Nov 2020 13:04:47 +0100
 
+python-sqlalchemy-utils (0.36.3-2ubuntu2) groovy; urgency=medium
+
+  * debian/patches/e6ecee3364c1f6afc59f856cc578758587881d9e.patch:
+    - Add upstream fix for autopkgtests
+
+ -- Gianfranco Costamagna <locutusofborg@debian.org>  Fri, 25 Sep 2020 12:20:30 +0200
+
+python-sqlalchemy-utils (0.36.3-2ubuntu1) groovy; urgency=low
+
+  * Merge from Debian unstable.  Remaining changes:
+    - d/rules: Run tests in autopkgtests.
+    - d/t/control: Configure functional tests.
+    - d/t/python-sqlalchemy-utils: Setup and run functional tests.
+    - d/p/disable-dateutil-tests.patch: Remove dateutil tests.
+    - d/rules: Add note that we execute tests in autopkgtests.
+    - d/gbp.conf: Update gbp configuration file.
+    - d/control: Update Vcs-* links and maintainers.
+
+ -- Gianfranco Costamagna <locutusofborg@debian.org>  Fri, 25 Sep 2020 12:17:05 +0200
+
 python-sqlalchemy-utils (0.36.3-2) unstable; urgency=medium
 
   * Uploading to unstable.
@@ -111,6 +169,34 @@ python-sqlalchemy-utils (0.36.3-1) exper
 
  -- Thomas Goirand <zigo@debian.org>  Tue, 07 Apr 2020 12:45:26 +0200
 
+python-sqlalchemy-utils (0.36.1-0ubuntu2) groovy; urgency=medium
+
+  * Enable autopkgtests for python-sqlalchemy-utils.
+    - d/rules: Run tests in autopkgtests.
+    - d/t/control: Configure functional tests.
+    - d/t/python-sqlalchemy-utils: Setup and run functional tests.
+    - d/p/disable-dateutil-tests.patch: Remove dateutil tests.
+    - d/rules: Add note that we execute tests in autopkgtests.
+
+ -- Chris MacNaughton <chris.macnaughton@canonical.com>  Wed, 24 Jun 2020 12:57:10 +0000
+
+python-sqlalchemy-utils (0.36.1-0ubuntu1) focal; urgency=medium
+
+  * New upstream release.
+
+ -- Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>  Wed, 05 Feb 2020 12:42:11 +0100
+
+python-sqlalchemy-utils (0.36.0-0ubuntu1) focal; urgency=medium
+
+  [ Corey Bryant ]
+  * d/gbp.conf: Update gbp configuration file.
+  * d/control: Update Vcs-* links and maintainers.
+
+  [ Sahid Orentino Ferdjaoui ]
+  * New upstream release.
+
+ -- Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>  Thu, 19 Dec 2019 16:13:47 +0100
+
 python-sqlalchemy-utils (0.32.21-2) unstable; urgency=medium
 
   * Team upload.
@@ -206,3 +292,4 @@ python-sqlalchemy-utils (0.30.12-1) unst
   * Initial release. (Closes: #798561)
 
  -- Thomas Goirand <zigo@debian.org>  Fri, 27 Mar 2015 16:18:57 +0100
+
diff -pruN 0.41.0-5/debian/control 0.41.1-0ubuntu1/debian/control
--- 0.41.0-5/debian/control	2024-12-16 15:07:27.000000000 +0000
+++ 0.41.1-0ubuntu1/debian/control	2023-12-05 00:17:38.000000000 +0000
@@ -1,7 +1,8 @@
 Source: python-sqlalchemy-utils
 Section: python
 Priority: optional
-Maintainer: Debian OpenStack <team+openstack@tracker.debian.org>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Debian OpenStack <team+openstack@tracker.debian.org>
 Uploaders:
  Thomas Goirand <zigo@debian.org>,
 Build-Depends:
@@ -15,10 +16,14 @@ Build-Depends-Indep:
  python3-dateutil,
  python3-flexmock,
  python3-infinity,
+ python3-intervals,
  python3-isort,
+ python3-mock,
  python3-psycopg2,
+ python3-psycopg2cffi,
  python3-pymysql,
  python3-pytest,
+ python3-six,
  python3-sqlalchemy,
  python3-tz,
 Standards-Version: 4.5.0
@@ -45,12 +50,15 @@ Architecture: all
 Depends:
  python3-arrow,
  python3-babel,
- python3-infinity,
+ python3-six,
  python3-sqlalchemy,
  ${misc:Depends},
  ${python3:Depends},
 Suggests:
  python-sqlalchemy-utils-doc,
+ python3-infinity,
+ python3-intervals,
+ python3-psycopg2cffi,
 Description: various utility functions for SQLAlchemy - Python 3.x
  Various utility functions and custom data types for SQLAlchemy.
  .
diff -pruN 0.41.0-5/debian/patches/remove-intersphinx.patch 0.41.1-0ubuntu1/debian/patches/remove-intersphinx.patch
--- 0.41.0-5/debian/patches/remove-intersphinx.patch	2024-12-16 15:07:27.000000000 +0000
+++ 0.41.1-0ubuntu1/debian/patches/remove-intersphinx.patch	1970-01-01 00:00:00.000000000 +0000
@@ -1,17 +0,0 @@
-Description: Remove intersphinx
-Author: Thomas Goirand <zigo@debian.org>
-Bug-Debian: https://bugs.debian.org/1090161
-Forwarded: no
-Last-Update: 2024-12-16
-
---- python-sqlalchemy-utils-0.41.0.orig/docs/conf.py
-+++ python-sqlalchemy-utils-0.41.0/docs/conf.py
-@@ -25,7 +25,7 @@ from sqlalchemy_utils import __version__
- 
- # Add any Sphinx extension module names here, as strings. They can be extensions
- # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
--extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
-+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
- 
- # Add any paths that contain templates here, relative to this directory.
- templates_path = ['_templates']
diff -pruN 0.41.0-5/debian/patches/series 0.41.1-0ubuntu1/debian/patches/series
--- 0.41.0-5/debian/patches/series	2024-12-16 15:07:27.000000000 +0000
+++ 0.41.1-0ubuntu1/debian/patches/series	1970-01-01 00:00:00.000000000 +0000
@@ -1 +0,0 @@
-remove-intersphinx.patch
diff -pruN 0.41.0-5/debian/rules 0.41.1-0ubuntu1/debian/rules
--- 0.41.0-5/debian/rules	2024-12-16 15:07:27.000000000 +0000
+++ 0.41.1-0ubuntu1/debian/rules	2023-12-05 00:17:38.000000000 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/make -f
 
 UPSTREAM_GIT := https://github.com/kvesteri/sqlalchemy-utils.git
-include /usr/share/openstack-pkg-tools/pkgos.make
+-include /usr/share/openstack-pkg-tools/pkgos.make
 
 export PYBUILD_NAME=sqlalchemy-utils
 
diff -pruN 0.41.0-5/debian/tests/control 0.41.1-0ubuntu1/debian/tests/control
--- 0.41.0-5/debian/tests/control	1970-01-01 00:00:00.000000000 +0000
+++ 0.41.1-0ubuntu1/debian/tests/control	2023-12-05 00:17:38.000000000 +0000
@@ -0,0 +1,12 @@
+Tests: python-sqlalchemy-utils
+Depends:
+ @, @builddeps@,
+ mysql-server,
+ postgresql-all,
+ python3-colour,
+ python3-cryptography,
+ python3-phonenumbers,
+ python3-pg,
+ python3-pg8000,
+Restrictions: needs-root, allow-stderr
+
diff -pruN 0.41.0-5/debian/tests/python-sqlalchemy-utils 0.41.1-0ubuntu1/debian/tests/python-sqlalchemy-utils
--- 0.41.0-5/debian/tests/python-sqlalchemy-utils	1970-01-01 00:00:00.000000000 +0000
+++ 0.41.1-0ubuntu1/debian/tests/python-sqlalchemy-utils	2023-12-05 00:17:38.000000000 +0000
@@ -0,0 +1,31 @@
+#!/bin/bash
+#---------------------
+# Testing sqlalchemy-utils
+#---------------------
+ret=0
+
+# Prepare Postgres and Mysql
+sed  -i 's/local\s\+all\s\+postgres\s\+peer/local all postgres trust\nhost all postgres 127.0.0.1\/32 trust/' /etc/postgresql/*/main/pg_hba.conf
+echo "default-authentication-plugin=mysql_native_password" >> /etc/mysql/mysql.conf.d/mysqld.cnf
+systemctl restart postgresql
+systemctl restart mysql
+
+# Cleanup existing test databases
+psql -c 'drop database sqlalchemy_utils_test;' -U postgres
+psql -c "ALTER USER postgres PASSWORD 'password';" -U postgres
+mysql -e 'drop database sqlalchemy_utils_test;'
+mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';"
+
+set -e
+# Setup test databases
+psql -c 'create database sqlalchemy_utils_test;' -U postgres
+psql -c 'create extension hstore;' -d sqlalchemy_utils_test -U postgres
+mysql -e 'create database sqlalchemy_utils_test;'
+
+export SQLALCHEMY_UTILS_TEST_MYSQL_USER="root"
+export SQLALCHEMY_UTILS_TEST_POSTGRESQL_USER="postgres"
+export SQLALCHEMY_UTILS_TEST_DB="sqlalchemy_utils_test"
+export SQLALCHEMY_UTILS_TEST_POSTGRESQL_PASSWORD="password"
+
+# Run tests
+pytest-3 sqlalchemy_utils tests
diff -pruN 0.41.0-5/sqlalchemy_utils/__init__.py 0.41.1-0ubuntu1/sqlalchemy_utils/__init__.py
--- 0.41.0-5/sqlalchemy_utils/__init__.py	2023-04-13 10:36:30.000000000 +0000
+++ 0.41.1-0ubuntu1/sqlalchemy_utils/__init__.py	2023-04-27 11:28:21.000000000 +0000
@@ -101,4 +101,4 @@ from .view import (  # noqa
     refresh_materialized_view
 )
 
-__version__ = '0.41.0'
+__version__ = '0.41.1'
diff -pruN 0.41.0-5/sqlalchemy_utils/view.py 0.41.1-0ubuntu1/sqlalchemy_utils/view.py
--- 0.41.0-5/sqlalchemy_utils/view.py	2023-04-13 10:36:30.000000000 +0000
+++ 0.41.1-0ubuntu1/sqlalchemy_utils/view.py	2023-04-27 11:28:21.000000000 +0000
@@ -1,6 +1,7 @@
 import sqlalchemy as sa
 from sqlalchemy.ext import compiler
 from sqlalchemy.schema import DDLElement, PrimaryKeyConstraint
+from sqlalchemy.sql.expression import ClauseElement, Executable
 
 from sqlalchemy_utils.functions import get_columns
 
@@ -178,6 +179,22 @@ def create_view(
     return table
 
 
+class RefreshMaterializedView(Executable, ClauseElement):
+    inherit_cache = True
+
+    def __init__(self, name, concurrently):
+        self.name = name
+        self.concurrently = concurrently
+
+
+@compiler.compiles(RefreshMaterializedView)
+def compile_refresh_materialized_view(element, compiler):
+    return 'REFRESH MATERIALIZED VIEW {concurrently}{name}'.format(
+        concurrently='CONCURRENTLY ' if element.concurrently else '',
+        name=compiler.dialect.identifier_preparer.quote(element.name),
+    )
+
+
 def refresh_materialized_view(session, name, concurrently=False):
     """ Refreshes an already existing materialized view
 
@@ -190,9 +207,4 @@ def refresh_materialized_view(session, n
     # Since session.execute() bypasses autoflush, we must manually flush in
     # order to include newly-created/modified objects in the refresh.
     session.flush()
-    session.execute(
-        sa.text('REFRESH MATERIALIZED VIEW {}{}'.format(
-            'CONCURRENTLY ' if concurrently else '',
-            session.bind.engine.dialect.identifier_preparer.quote(name)
-        ))
-    )
+    session.execute(RefreshMaterializedView(name, concurrently))
