Skip to content

Dbc#92

Open
Lynndabel wants to merge 10 commits into
Quantarq:mainfrom
Lynndabel:dbc
Open

Dbc#92
Lynndabel wants to merge 10 commits into
Quantarq:mainfrom
Lynndabel:dbc

Conversation

@Lynndabel

Copy link
Copy Markdown

I have completed the refactoring of the database connector hierarchy to resolve a fragile "diamond" inheritance pattern and eliminate redundant SQLAlchemy engine instantiations. The system now uses a composition-based architecture with dependency injection.

Changes Made
Core Database Configuration
[MODIFY]
base.py
Updated DBConnector.init to accept an optional engine. If no engine is provided, it defaults to creating a new one (maintaining backward compatibility where needed), but it now enables sharing a single engine across all connectors.

Closes #75

@YaronZaki YaronZaki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling #75 — the composition-based approach is the right direction. CI is currently failing on the and jobs though, so we can't merge yet. Could you rebase on main and investigate? The refactor likely broke some existing imports / fixtures that depend on the old inheritance shape.

Copy link
Copy Markdown
Contributor

Hi @Lynndabel 👋 Nice refactor moving from inheritance to composition — composition over inheritance is the right call for the db layer, and consolidating engine instantiations is a real win. Unfortunately the branch has merge conflicts against the current main now. Could you rebase onto the latest main and update the PR? The approach looks great and we should be able to merge right after. Thanks for tackling #75! 💪

@YaronZaki YaronZaki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Composition over inheritance is the right move here, much cleaner architecture. CI is failing on the unit + integration tests though — please fix and push again before we can land it.

Copy link
Copy Markdown
Contributor

Hi @Lynndabel — moving CRUD modules off the inheritance chain in favor of an injected DBConnector is a solid refactor; the global db_connector in database.py is a sensible default. CI is failing on:

ImportError: cannot import name 'AirDrop' from partially initialized module 'web_app.db.models' (most likely due to a circular import)

Looks like a model import-ordering issue crept in with the refactor. Check the top-of-file imports in web_app/db/models.py and any CRUD module that imports from it — possible that an import inside a class body or late-binding is causing the loop. Once CI is green, easy merge. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Refactor PositionDBConnector deep inheritance to composition

2 participants