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

feat: update sqlalchemy to use standard api instead of async one, standard has better documentation, more community support, and cleaner code #276

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

lchen-2101
Copy link
Collaborator

closes #275

…ndard has better documentation, more community support, and cleaner code
Copy link

github-actions bot commented Dec 23, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/regtech_user_fi_management
  config.py
  dependencies.py
  main.py 44
  src/regtech_user_fi_management/entities
  listeners.py 71-72
  src/regtech_user_fi_management/entities/engine
  engine.py
  src/regtech_user_fi_management/entities/models
  dao.py
  src/regtech_user_fi_management/entities/repos
  institutions_repo.py
  repo_utils.py
  src/regtech_user_fi_management/routers
  institutions.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Contributor

@jcadam14 jcadam14 left a comment

Choose a reason for hiding this comment

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

Just a couple of questions in the comments, but looks good.

elif d := domain.strip():
query = query.join(FinancialInstitutionDomainDao).filter(FinancialInstitutionDomainDao.domain == d)
return query.limit(count).offset(page * count).all()

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the more verbose code that was simplified here, particularly the options call, was omitted because we're already defining in the model the lazy selectin (so doing an options(joinedload...) is redundant)?

This looks much nicer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I think the joinedload was before the lazy selectin change (kinda defeats the purpose of having lazy fetch, but all in the past now 😂); and yeap, I like the query and filter apis better

load the async relational attributes so dto can be properly serialized
"""
for type in fi.sbl_institution_types:
await type.awaitable_attrs.sbl_type
Copy link
Contributor

Choose a reason for hiding this comment

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

what was the purpose of this? Just forcing a reload of relationship data in the model? Seemed unnecessary? Good cleanup!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it was because the relational model was another nest deeper, so it couldn't populate the 2nd layer of nested relationship if I recall correctly, so awaitable_attrs was needed; the standard apis don't have this concern during my testing.

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.

Switch sqlalchemy to use standard API instead of async
2 participants