diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ae7825..307ba84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,6 @@ All notable changes to WuttJamaican will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## v0.21.0 (2025-06-29) - -### Feat - -- remove version cap for SQLAlchemy (allow 1.x or 2.x) - ## v0.20.6 (2025-06-29) ### Fix diff --git a/pyproject.toml b/pyproject.toml index 954a7a0..c625694 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttJamaican" -version = "0.21.1" +version = "0.20.6" description = "Base package for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}] @@ -38,7 +38,7 @@ dependencies = [ [project.optional-dependencies] -db = ["SQLAlchemy", "alembic", "alembic-postgresql-enum", "passlib"] +db = ["SQLAlchemy<2", "alembic", "alembic-postgresql-enum", "passlib"] docs = ["Sphinx", "sphinxcontrib-programoutput", "enum-tools[sphinx]", "furo"] tests = ["pytest-cov", "tox"] diff --git a/src/wuttjamaican/db/handler.py b/src/wuttjamaican/db/handler.py index 849f954..7c745d8 100644 --- a/src/wuttjamaican/db/handler.py +++ b/src/wuttjamaican/db/handler.py @@ -34,10 +34,6 @@ class DatabaseHandler(GenericHandler): Base class and default implementation for the :term:`db handler`. """ - def get_dialect(self, bind): - """ """ - return bind.url.get_dialect().name - def next_counter_value(self, session, key): """ Return the next counter value for the given key. @@ -56,7 +52,7 @@ class DatabaseHandler(GenericHandler): :returns: Next value as integer. """ - dialect = self.get_dialect(session.bind) + dialect = session.bind.url.get_dialect().name # postgres uses "true" native sequence if dialect == 'postgresql': diff --git a/src/wuttjamaican/db/util.py b/src/wuttjamaican/db/util.py index ff4b69b..bc06e22 100644 --- a/src/wuttjamaican/db/util.py +++ b/src/wuttjamaican/db/util.py @@ -25,8 +25,6 @@ Database Utilities """ import uuid as _uuid -from importlib.metadata import version -from packaging.version import Version import sqlalchemy as sa from sqlalchemy import orm @@ -46,11 +44,6 @@ naming_convention = { } -SA2 = True -if Version(version('SQLAlchemy')) < Version('2'): # pragma: no cover - SA2 = False - - class ModelBase: """ """ diff --git a/tests/db/test_handler.py b/tests/db/test_handler.py index bee05e5..e28e813 100644 --- a/tests/db/test_handler.py +++ b/tests/db/test_handler.py @@ -51,7 +51,8 @@ else: # using sqlite backend. # using postgres as backend, should use "sequence" - with patch.object(handler, 'get_dialect', return_value='postgresql'): + with patch.object(self.session.bind.url, 'get_dialect') as get_dialect: + get_dialect.return_value.name = 'postgresql' with patch.object(self.session, 'execute') as execute: execute.return_value.scalar.return_value = 1 value = handler.next_counter_value(self.session, 'testing') diff --git a/tests/test_install.py b/tests/test_install.py index 2bc2ddb..ba410b1 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -92,8 +92,6 @@ class TestInstallHandler(ConfigTestCase): except ImportError: pytest.skip("test is not relevant without sqlalchemy") - from wuttjamaican.db.util import SA2 - handler = self.make_handler() def prompt_generic(info, default=None, is_password=False): @@ -114,8 +112,6 @@ class TestInstallHandler(ConfigTestCase): self.assertRaises(RuntimeError, handler.get_dbinfo) sys.exit.assert_called_once_with(1) - seekrit = '***' if SA2 else 'seekrit' - # good dbinfo sys.exit.reset_mock() test_db_connection.return_value = None @@ -123,7 +119,7 @@ class TestInstallHandler(ConfigTestCase): self.assertFalse(sys.exit.called) rprint.assert_called_with("[bold green]good[/bold green]") self.assertEqual(str(dbinfo['dburl']), - f'postgresql+psycopg2://poser:{seekrit}@localhost:5432/poser') + 'postgresql+psycopg2://poser:seekrit@localhost:5432/poser') def test_make_db_url(self): try: @@ -131,16 +127,13 @@ class TestInstallHandler(ConfigTestCase): except ImportError: pytest.skip("test is not relevant without sqlalchemy") - from wuttjamaican.db.util import SA2 - handler = self.make_handler() - seekrit = '***' if SA2 else 'seekrit' url = handler.make_db_url('postgresql', 'localhost', '5432', 'poser', 'poser', 'seekrit') - self.assertEqual(str(url), f'postgresql+psycopg2://poser:{seekrit}@localhost:5432/poser') + self.assertEqual(str(url), 'postgresql+psycopg2://poser:seekrit@localhost:5432/poser') url = handler.make_db_url('mysql', 'localhost', '3306', 'poser', 'poser', 'seekrit') - self.assertEqual(str(url), f'mysql+mysqlconnector://poser:{seekrit}@localhost:3306/poser') + self.assertEqual(str(url), 'mysql+mysqlconnector://poser:seekrit@localhost:3306/poser') def test_test_db_connection(self): try: