Rewrote the data model declaration of the test site with the mapped type hint and the mapped columns in SQLAlchemy 2.0.
This commit is contained in:
parent
f6567794e0
commit
d5c1be3d80
@ -21,6 +21,7 @@ import typing as t
|
|||||||
|
|
||||||
from flask import Blueprint, render_template, Flask, redirect, url_for, \
|
from flask import Blueprint, render_template, Flask, redirect, url_for, \
|
||||||
session, request, g, Response, abort
|
session, request, g, Response, abort
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
|
||||||
from . import db
|
from . import db
|
||||||
|
|
||||||
@ -32,10 +33,9 @@ class User(db.Model):
|
|||||||
"""A user."""
|
"""A user."""
|
||||||
__tablename__ = "users"
|
__tablename__ = "users"
|
||||||
"""The table name."""
|
"""The table name."""
|
||||||
id = db.Column(db.Integer, nullable=False, primary_key=True,
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||||
autoincrement=True)
|
"""The ID."""
|
||||||
"""The ID"""
|
username: Mapped[str] = mapped_column(unique=True)
|
||||||
username = db.Column(db.String, nullable=False, unique=True)
|
|
||||||
"""The username."""
|
"""The username."""
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user