Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates prior to SQLAlchemy 2.0 upgrade #386

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

martinburchell
Copy link
Collaborator

Changes for SQLAlchemy 2.0 that are compatible with 1.4 to reduce the number of changes in #385.

I've fixed anything that was broken in the Python tests with deprecation warnings enabled:

SQLALCHEMY_WARN_20=1 pytest -W error::sqlalchemy.exc.RemovedIn20Warning -W error::sqlalchemy.exc.MovedIn20Warning -W error::SADeprecationWarning

I've also fixed any other legacy calls to select() with the columns given in a single list argument. I've added tests where these cases weren't covered.
I've also changed the task test factories to number IDs from 1 instead of 0 and fixed a flaky webview test, which wrongly assumed object IDs would appear in a certain order.

I have not been able to test merge_db.py as I couldn't get it to work.
This error was with two recently created databases:

File "/home/martinb/.virtualenvs/camcops/bin/camcops_server", line 8, in <module>
  sys.exit(main())

File "/home/martinb/workspace/camcops/server/camcops_server/camcops_server.py", line 1593, in main
  retval = camcops_main()

File "/home/martinb/workspace/camcops/server/camcops_server/camcops_server.py", line 1520, in camcops_main
  success = progargs.func(progargs)  # type: Optional[bool]

File "/home/martinb/workspace/camcops/server/camcops_server/camcops_server.py", line 1044, in <lambda>
  func=lambda args: _merge_camcops_db(

File "/home/martinb/workspace/camcops/server/camcops_server/camcops_server.py", line 285, in _merge_camcops_db
  merge_camcops_db(
File "/home/martinb/workspace/camcops/server/camcops_server/cc_modules/merge_db.py", line 1256, in merge_camcops_db
  merge_db(
File "/home/martinb/.virtualenvs/camcops/lib/python3.9/site-packages/cardinal_pythonlib/sqlalchemy/merge_db.py", line 972, in merge_db
  rewrite_relationships(

File "/home/martinb/.virtualenvs/camcops/lib/python3.9/site-packages/cardinal_pythonlib/sqlalchemy/orm_inspect.py", line 445, in rewrite_relationships
  related_new = objmap[related_old]
KeyError: <camcops_server.cc_modules.cc_patient.Patient object at 0x7f91a9b070d0>

Some of the code in the client API appears not to be reached so can't easily be tested
@martinburchell martinburchell marked this pull request as ready for review February 6, 2025 14:35
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.

1 participant