apply exact Python types as needed using Mapped

pull/22644/head
Asuka Minato 7 months ago
parent 9d28f9b865
commit 79741fa8a4

@ -67,7 +67,7 @@ class PGVectoRS(BaseVector):
postgresql.UUID(as_uuid=True),
primary_key=True,
)
text: Mapped[str] = mapped_column(String)
text: Mapped[str]
meta: Mapped[dict] = mapped_column(postgresql.JSONB)
vector: Mapped[ndarray] = mapped_column(VECTOR(dim))

@ -85,18 +85,20 @@ class Account(UserMixin, Base):
__table_args__ = (db.PrimaryKeyConstraint("id", name="account_pkey"), db.Index("account_email_idx", "email"))
id: Mapped[str] = mapped_column(StringUUID, server_default=db.text("uuid_generate_v4()"))
name = mapped_column(db.String(255), nullable=False)
email = mapped_column(db.String(255), nullable=False)
password = mapped_column(db.String(255), nullable=True)
password_salt = mapped_column(db.String(255), nullable=True)
avatar = mapped_column(db.String(255))
interface_language = mapped_column(db.String(255))
interface_theme = mapped_column(db.String(255))
timezone = mapped_column(db.String(255))
name: Mapped[str] = mapped_column(db.String(255))
email: Mapped[str] = mapped_column(db.String(255))
password: Mapped[Optional[str]] = mapped_column(db.String(255))
password_salt: Mapped[Optional[str]] = mapped_column(db.String(255))
avatar: Mapped[str] = mapped_column(db.String(255))
interface_language: Mapped[str] = mapped_column(db.String(255))
interface_theme: Mapped[str] = mapped_column(db.String(255))
timezone: Mapped[str] = mapped_column(db.String(255))
last_login_at = mapped_column(db.DateTime)
last_login_ip = mapped_column(db.String(255))
last_login_ip: Mapped[str] = mapped_column(db.String(255))
last_active_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())
status = mapped_column(db.String(16), nullable=False, server_default=db.text("'active'::character varying"))
status: Mapped[str] = mapped_column(
db.String(16), nullable=False, server_default=db.text("'active'::character varying")
)
initialized_at = mapped_column(db.DateTime)
created_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())
updated_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())
@ -197,10 +199,10 @@ class Tenant(Base):
__table_args__ = (db.PrimaryKeyConstraint("id", name="tenant_pkey"),)
id: Mapped[str] = mapped_column(StringUUID, server_default=db.text("uuid_generate_v4()"))
name = mapped_column(db.String(255), nullable=False)
name: Mapped[str] = mapped_column(db.String(255))
encrypt_public_key = mapped_column(db.Text)
plan = mapped_column(db.String(255), nullable=False, server_default=db.text("'basic'::character varying"))
status = mapped_column(db.String(255), nullable=False, server_default=db.text("'normal'::character varying"))
plan: Mapped[str] = mapped_column(db.String(255), server_default=db.text("'basic'::character varying"))
status: Mapped[str] = mapped_column(db.String(255), server_default=db.text("'normal'::character varying"))
custom_config = mapped_column(db.Text)
created_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())
updated_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())
@ -251,8 +253,8 @@ class AccountIntegrate(Base):
id = mapped_column(StringUUID, server_default=db.text("uuid_generate_v4()"))
account_id = mapped_column(StringUUID, nullable=False)
provider = mapped_column(db.String(16), nullable=False)
open_id = mapped_column(db.String(255), nullable=False)
encrypted_token = mapped_column(db.String(255), nullable=False)
open_id: Mapped[str] = mapped_column(db.String(255))
encrypted_token: Mapped[str] = mapped_column(db.String(255))
created_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())
updated_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())

@ -1,3 +1,4 @@
from typing import Optional
import base64
import enum
import hashlib
@ -47,19 +48,19 @@ class Dataset(Base):
id = mapped_column(StringUUID, server_default=db.text("uuid_generate_v4()"))
tenant_id = mapped_column(StringUUID, nullable=False)
name = mapped_column(db.String(255), nullable=False)
name: Mapped[str] = mapped_column(db.String(255))
description = mapped_column(db.Text, nullable=True)
provider = mapped_column(db.String(255), nullable=False, server_default=db.text("'vendor'::character varying"))
permission = mapped_column(db.String(255), nullable=False, server_default=db.text("'only_me'::character varying"))
data_source_type = mapped_column(db.String(255))
indexing_technique = mapped_column(db.String(255), nullable=True)
provider: Mapped[str] = mapped_column(db.String(255), server_default=db.text("'vendor'::character varying"))
permission: Mapped[str] = mapped_column(db.String(255), server_default=db.text("'only_me'::character varying"))
data_source_type: Mapped[str] = mapped_column(db.String(255))
indexing_technique: Mapped[Optional[str]] = mapped_column(db.String(255))
index_struct = mapped_column(db.Text, nullable=True)
created_by = mapped_column(StringUUID, nullable=False)
created_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())
updated_by = mapped_column(StringUUID, nullable=True)
updated_at = mapped_column(db.DateTime, nullable=False, server_default=func.current_timestamp())
embedding_model = mapped_column(db.String(255), nullable=True)
embedding_model_provider = mapped_column(db.String(255), nullable=True)
embedding_model: Mapped[str] = mapped_column(db.String(255), nullable=True)
embedding_model_provider: Mapped[str] = mapped_column(db.String(255), nullable=True)
collection_binding_id = mapped_column(StringUUID, nullable=True)
retrieval_model = mapped_column(JSONB, nullable=True)
built_in_field_enabled = mapped_column(db.Boolean, nullable=False, server_default=db.text("false"))

Loading…
Cancel
Save