Skip to content

Commit

Permalink
Merge pull request #702 from kvesteri/release/0.41.0
Browse files Browse the repository at this point in the history
Release 0.41.0
  • Loading branch information
kurtmckee committed Apr 13, 2023
2 parents 0c158eb + 69ea39e commit eb3b9e0
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: flake8

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.11.5
hooks:
- id: isort

Expand Down
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Changelog
Here you can see the full list of changes between each SQLAlchemy-Utils release.


0.41.0 (2023-04-13)
^^^^^^^^^^^^^^^^^^^

- Support psycopg3 for ``create_database()`` and ``delete_database()``.
(#701, pull request by LerikP)


0.40.0 (2023-02-12)
^^^^^^^^^^^^^^^^^^^

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def get_version():
'Jinja2>=2.3',
'docutils>=0.10',
'flexmock>=0.9.7',
'psycopg>=3.1.8',
'psycopg2>=2.5.1',
'psycopg2cffi>=2.8.1',
'pg8000>=1.12.4',
Expand Down
2 changes: 1 addition & 1 deletion sqlalchemy_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@
refresh_materialized_view
)

__version__ = '0.40.0'
__version__ = '0.41.0'
2 changes: 1 addition & 1 deletion sqlalchemy_utils/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
.. _column_property:
https://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#using-column-property
https://docs.sqlalchemy.org/en/latest/orm/mapped_sql_expr.html#using-column-property
.. _counter_culture: https://github.com/magnusvk/counter_culture
.. _stackoverflow reply by Michael Bayer:
https://stackoverflow.com/a/13765857/520932
Expand Down
4 changes: 2 additions & 2 deletions sqlalchemy_utils/functions/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def create_database(url, encoding='utf8', template=None):

if (dialect_name == 'mssql' and dialect_driver in {'pymssql', 'pyodbc'}) \
or (dialect_name == 'postgresql' and dialect_driver in {
'asyncpg', 'pg8000', 'psycopg2', 'psycopg2cffi'}):
'asyncpg', 'pg8000', 'psycopg', 'psycopg2', 'psycopg2cffi'}):
engine = sa.create_engine(url, isolation_level='AUTOCOMMIT')
else:
engine = sa.create_engine(url)
Expand Down Expand Up @@ -625,7 +625,7 @@ def drop_database(url):
if dialect_name == 'mssql' and dialect_driver in {'pymssql', 'pyodbc'}:
engine = sa.create_engine(url, connect_args={'autocommit': True})
elif dialect_name == 'postgresql' and dialect_driver in {
'asyncpg', 'pg8000', 'psycopg2', 'psycopg2cffi'}:
'asyncpg', 'pg8000', 'psycopg', 'psycopg2', 'psycopg2cffi'}:
engine = sa.create_engine(url, isolation_level='AUTOCOMMIT')
else:
engine = sa.create_engine(url)
Expand Down
2 changes: 1 addition & 1 deletion sqlalchemy_utils/types/ts_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Article(Base):
Would be equivalent to SQL::
search_vector @@ to_tsquery('pg_catalog.simgle', 'finland')
search_vector @@ to_tsquery('pg_catalog.simple', 'finland')
"""
impl = TSVECTOR
Expand Down
15 changes: 15 additions & 0 deletions tests/functions/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
import sqlalchemy as sa

from sqlalchemy_utils import create_database, database_exists, drop_database
from sqlalchemy_utils.compat import get_sqlalchemy_version

pymysql = None
try:
import pymysql # noqa
except ImportError:
pass

sqlalchemy_version = get_sqlalchemy_version()


class DatabaseTest:
def test_create_and_drop(self, dsn):
Expand Down Expand Up @@ -98,6 +101,18 @@ def dsn(self, postgresql_db_user, postgresql_db_password):
)


@pytest.mark.skipif('sqlalchemy_version < (2, 0, 0)')
class TestDatabasePostgresPsycoPG3(DatabaseTest):

@pytest.fixture
def dsn(self, postgresql_db_user, postgresql_db_password):
return 'postgresql+psycopg://{}:{}@localhost/{}'.format(
postgresql_db_user,
postgresql_db_password,
'db_to_test_create_and_drop_via_psycopg3_driver'
)


@pytest.mark.usefixtures('postgresql_dsn')
class TestDatabasePostgresWithQuotedName(DatabaseTest):

Expand Down

0 comments on commit eb3b9e0

Please sign in to comment.