From 4798087be157a9816201f0d9591e9e48f679d836 Mon Sep 17 00:00:00 2001 From: Michelle Tran Date: Tue, 19 Nov 2024 14:39:28 -0500 Subject: [PATCH] Fix SQLAlchemy upgrade incompatibilities There's a few things that were fixed for the SQLAlchemy upgrade. --- database/engine.py | 2 +- database/tests/unit/test_engine.py | 1 + docker/test_codecov_config.yml | 4 ++-- tasks/delete_owner.py | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/database/engine.py b/database/engine.py index 864587723..90dbda95b 100644 --- a/database/engine.py +++ b/database/engine.py @@ -54,7 +54,7 @@ def create_session(self): timeseries_engine = self.timeseries_engine class RoutingSession(Session): - def get_bind(self, mapper=None, clause=None): + def get_bind(self, mapper=None, clause=None, **kw): if mapper is not None and issubclass( mapper.class_, TimeseriesBaseModel ): diff --git a/database/tests/unit/test_engine.py b/database/tests/unit/test_engine.py index a5665a279..44b6148ab 100644 --- a/database/tests/unit/test_engine.py +++ b/database/tests/unit/test_engine.py @@ -39,6 +39,7 @@ def test_session_get_bind_timeseries_enabled(self, sqlalchemy_connect_url, mocke database_url=sqlalchemy_connect_url, timeseries_database_url=sqlalchemy_connect_url, ) + session = session_factory.create_session() assert session_factory.main_engine is not None assert session_factory.timeseries_engine is not None diff --git a/docker/test_codecov_config.yml b/docker/test_codecov_config.yml index 4f729f3fb..b567f5fb0 100644 --- a/docker/test_codecov_config.yml +++ b/docker/test_codecov_config.yml @@ -5,8 +5,8 @@ setup: encryption_secret: "zp^P9*i8aR3" services: - database_url: postgres://postgres:password@postgres:5432/postgres - timeseries_database_url: postgres://postgres:password@timescale:5432/postgres + database_url: postgresql://postgres:password@postgres:5432/postgres + timeseries_database_url: postgresql://postgres:password@timescale:5432/postgres redis_url: redis://redis:6379 minio: hash_key: testixik8qdauiab1yiffydimvi72ekq # never change this diff --git a/tasks/delete_owner.py b/tasks/delete_owner.py index fa7073164..bc73ff739 100644 --- a/tasks/delete_owner.py +++ b/tasks/delete_owner.py @@ -67,7 +67,7 @@ def delete_from_database(self, db_session, owner): ) db_session.commit() log.info("Deleting repos from DB", extra=dict(ownerid=ownerid)) - involved_repos.delete() + db_session.query(Repository).filter(Repository.ownerid == ownerid).delete() db_session.commit() log.info("Setting other owner bots to NULL", extra=dict(ownerid=ownerid)) db_session.query(Owner).filter(Owner.bot_id == ownerid).update( @@ -77,7 +77,7 @@ def delete_from_database(self, db_session, owner): log.info( "Cleaning repos that have this owner as bot", extra=dict(ownerid=ownerid) ) - db_session.query(Repository.repoid).filter(Repository.bot_id == ownerid).update( + db_session.query(Repository).filter(Repository.bot_id == ownerid).update( {Repository.bot_id: None}, synchronize_session=False ) db_session.commit()