From 8b629be1db0d994c3e06afc16a83631cddfb42f2 Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Wed, 29 Oct 2014 14:21:29 +0200 Subject: [PATCH] Update changes, refactor drop_database --- CHANGES.rst | 1 + sqlalchemy_utils/functions/database.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index c79a45e..41d03ec 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,7 @@ Here you can see the full list of changes between each SQLAlchemy-Utils release. ^^^^^^^^^^^^^^^^^^^ - Fixed assert_max_length not working with non nullable columns +- Add PostgreSQL < 9.2 support for drop_database 0.27.5 (2014-10-24) diff --git a/sqlalchemy_utils/functions/database.py b/sqlalchemy_utils/functions/database.py index ff847a5..c48f62a 100644 --- a/sqlalchemy_utils/functions/database.py +++ b/sqlalchemy_utils/functions/database.py @@ -399,8 +399,15 @@ def drop_database(url): engine.raw_connection().set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) # Disconnect all users from the database we are dropping. - version = list(map(int, engine.execute('SHOW server_version;').first()[0].split('.'))) - pid_column = 'pid' if (version[0] >= 9 and version[1] >= 2) else 'procpid' + version = list( + map( + int, + engine.execute('SHOW server_version;').first()[0].split('.') + ) + ) + pid_column = ( + 'pid' if (version[0] >= 9 and version[1] >= 2) else 'procpid' + ) text = ''' SELECT pg_terminate_backend(pg_stat_activity.%(pid_column)s) FROM pg_stat_activity