3
0
Fork 0

Compare commits

..

No commits in common. "e38c45b15a85e338492c1a713f3123c964c46263" and "706ea80926bdcf8462be0bfdd057ef5d9d9442cc" have entirely different histories.

6 changed files with 8 additions and 31 deletions

View file

@ -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

View file

@ -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"]

View file

@ -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':

View file

@ -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:
""" """

View file

@ -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')

View file

@ -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: