Title: Fix/sqlalchemy 2.0 compatibility - chapter6 UoW by rickywesker · Pull Request #110 · cosmicpython/code · GitHub
Open Graph Title: Fix/sqlalchemy 2.0 compatibility - chapter6 UoW by rickywesker · Pull Request #110 · cosmicpython/code
X Title: Fix/sqlalchemy 2.0 compatibility - chapter6 UoW by rickywesker · Pull Request #110 · cosmicpython/code
Description: Hi Harry! 👋 I'm a reader following along with the Cosmic Python book, and I really enjoyed Chapter 6 on the Unit of Work pattern! While working through the exercises on the chapter_06_uow_exercise branch, I noticed the code wasn't compatible with SQLAlchemy 2.0, which caused some errors when running tests. So I made the necessary updates to get everything working smoothly. Changes orm.py: Replace deprecated mapper() with registry.map_imperatively() repository.py: Replace session.query() with session.scalars(select()) conftest.py: Replace clear_mappers() with mapper_registry.dispose() test_*.py: Wrap raw SQL strings with text() requirements.txt: Require sqlalchemy>=2.0 Test Results All existing tests pass (20 passed, 3 skipped, 4 failed). The 4 failed tests are expected - they are exercise-related tests designed to fail until the reader implements the UnitOfWork pattern. I hope this PR can help other readers who encounter the same issue, and save them some debugging time! 🙏 Thank you for writing such a great book! 📚
Open Graph Description: Hi Harry! 👋 I'm a reader following along with the Cosmic Python book, and I really enjoyed Chapter 6 on the Unit of Work pattern! While working through the exercises on the chapter_06_uow_exerc...
X Description: Hi Harry! 👋 I'm a reader following along with the Cosmic Python book, and I really enjoyed Chapter 6 on the Unit of Work pattern! While working through the exercises on the chapter_06_uow_e...
Opengraph URL: https://github.com/cosmicpython/code/pull/110
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:1e1fabbc-5be0-44d0-fe15-fa74744b0bdb |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | E77C:3930F2:E6D5066:12C7B684:69773BBE |
| html-safe-nonce | 21e5f93473af2c2a3bc1c9c817af628de9874634bb5adefbf4b77a9032eb689e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzdDOjM5MzBGMjpFNkQ1MDY2OjEyQzdCNjg0OjY5NzczQkJFIiwidmlzaXRvcl9pZCI6IjYyNzEyNjA1NTAxNDc1NTQyMzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3173a89578144e057666dfa033be9c87340ba22a1d23f0b3766b85813a108c97 |
| hovercard-subject-tag | pull_request:3168870330 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/cosmicpython/code/pull/110/checks |
| twitter:image | https://avatars.githubusercontent.com/u/20077033?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/20077033?s=400&v=4 |
| og:image:alt | Hi Harry! 👋 I'm a reader following along with the Cosmic Python book, and I really enjoyed Chapter 6 on the Unit of Work pattern! While working through the exercises on the chapter_06_uow_exerc... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| turbo-cache-control | no-preview |
| go-import | github.com/cosmicpython/code git https://github.com/cosmicpython/code.git |
| octolytics-dimension-user_id | 47350834 |
| octolytics-dimension-user_login | cosmicpython |
| octolytics-dimension-repository_id | 169221290 |
| octolytics-dimension-repository_nwo | cosmicpython/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 169221290 |
| octolytics-dimension-repository_network_root_nwo | cosmicpython/code |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f752335dbbea672610081196a1998e39aec5e14b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width