Implemented alembic migrations, added cursors closing task.

This commit is contained in:
2025-02-25 23:37:55 +03:00
parent 836ce1dc82
commit 1abc225923
17 changed files with 746 additions and 101 deletions

View File

@@ -124,8 +124,8 @@ class SelectQueryBase(BaseModel):
columns: Union[Literal["*"], List[str]] = "*"
filters: Optional[List[FilterClause]] = None
sort_by: Optional[List[SortClause]] = None
limit: Annotated[int, Field(strict=True, gt=0)] = None
offset: Annotated[int, Field(strict=True, ge=0)] = None
limit: Optional[Annotated[int, Field(strict=True, gt=0)]] = None
offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = None
@field_validator("table_name")
@classmethod
@@ -179,16 +179,20 @@ class SelectQueryInResult(BaseModel):
from_attributes = True
class SelectQueryMetaData(BaseModel):
cursor: Optional[UUID4] = Field(
None,
description="A UUID4 cursor for pagination. Can be None if no more data is available.",
)
total_number: int
has_more: bool = False
class CachedCursorOut(BaseModel):
id: UUID4 | None
connection_id: int
query: SelectQueryInResult
row_count: int
fetched_rows: int
is_closed: bool
has_more: bool
close_at: int
ttl: int
class Config:
from_attributes = True
class SelectResult(BaseModel):
meta: SelectQueryMetaData
query: SelectQueryInResult
cursor: CachedCursorOut
results: SelectResultData | None