Change ORM models to dataclassess #273

Open
opened 2023-06-08 12:33:37 +00:00 by kparal · 3 comments
Owner

SQLAlchemy 2.0 brought an option to use dataclasses as ORM models. That brings nice improvements, like not having to define __init__() methods, possibly more accurate type hints, and more. See more documentation.

Unfortunately, at this moment, it's not supported by Flask-SQLAlchemy, see this issue.

Once the issue is resolved, consider switching our ORM classes to dataclasses.

SQLAlchemy 2.0 brought an option to use [dataclasses as ORM models](https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#native-support-for-dataclasses-mapped-as-orm-models). That brings nice improvements, like not having to define `__init__()` methods, possibly more accurate type hints, and more. See [more documentation](https://docs.sqlalchemy.org/en/20/orm/dataclasses.html#orm-declarative-native-dataclasses). Unfortunately, at this moment, it's not supported by Flask-SQLAlchemy, see [this issue](https://github.com/pallets-eco/flask-sqlalchemy/issues/1140). Once the issue is resolved, consider switching our ORM classes to dataclasses.
Contributor

DeclarativeBase is now supported by a recent Flask-Sqlalchemy >= 3.1.0 release fyi.

DeclarativeBase is now supported by a recent Flask-Sqlalchemy >= 3.1.0 release fyi.
Author
Owner

Metadata Update from @kparal:

  • Custom field story_points adjusted to 3
**Metadata Update from @kparal**: - Custom field story_points adjusted to 3
Author
Owner

This is somewhat related to #306 and #317 - the mypy plugin is going away in SQLAlchemy 2.1 and for the purposes of type checking the tables need to be defined in a modern way:
https://docs.sqlalchemy.org/en/20/orm/extensions/mypy.html
https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#whatsnew-20-orm-declarative-typing

This is somewhat related to #306 and #317 - the mypy plugin is going away in SQLAlchemy 2.1 and for the purposes of type checking the tables need to be defined in a modern way: https://docs.sqlalchemy.org/en/20/orm/extensions/mypy.html https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#whatsnew-20-orm-declarative-typing
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quality/blockerbugs#273
No description provided.