Skip to content

[fix] Import declarative_base from sqlalchemy.orm - #5132

Open
Anandb71 wants to merge 1 commit into
Ericsson:masterfrom
Anandb71:fix/5116-declarative-base-import
Open

Anandb71 wants to merge 1 commit into
Ericsson:masterfrom
Anandb71:fix/5116-declarative-base-import

Conversation

@Anandb71

@Anandb71 Anandb71 commented Oct 6, 2026

Copy link
Copy Markdown

Fixes #5116

run_db_model.py imported declarative_base() from sqlalchemy.ext.declarative. Since the requirement is now sqlalchemy~=2.0.0, loading the module emits:

run_db_model.py:36: MovedIn20Warning: The ``declarative_base()`` function is now available as sqlalchemy.orm.declarative_base(). (deprecated since: 2.0)

This change imports it from sqlalchemy.orm instead, the same way config_db_model.py already does. Behaviour is unchanged: the sqlalchemy.orm function is the one the old location forwards to. No other module in the tree still uses sqlalchemy.ext.declarative.

Checked with SQLAlchemy 2.0.54:

  • python -W error::DeprecationWarning -c "import codechecker_server.database.run_db_model" raises MovedIn20Warning on master and imports cleanly with this change.
  • pytest tests/unit in web/server (thrift stubs generated locally, test_ccldap.py skipped because python-ldap isn't installed): the MovedIn20Warning that shows up in the warnings summary on master is gone; pass/fail counts are the same as master (47 passed; test_request_routing::test_post and the test_git_commit_url cases fail the same way on master in this environment). test_run_removal_lock.py, which imports run_db_model, passes.
  • pycodestyle (2.12.0) is clean, and pylint (3.2.x, repo .pylintrc) reports nothing new for the file.

run_db_model.py still imported declarative_base() from
sqlalchemy.ext.declarative, which SQLAlchemy 2.0 deprecates and reports
with a MovedIn20Warning whenever the module is loaded. Import it from
sqlalchemy.orm instead, as config_db_model.py already does.

Fixes Ericsson#5116
@Anandb71
Anandb71 requested a review from bruntib as a code owner October 6, 2026 22:55
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.

SQLAlchemy deprecation warning in CI

1 participant