fix: add server_default to script_template columns, refresh fork_point after commit
- script_template.py: add server_default for requires_elevation, is_gallery_featured, gallery_sort_order so Base.metadata.create_all emits proper SQL DEFAULTs (test fixtures use raw SQL INSERT) - session_branches.py: refresh fork_point after commit so JSONB options field is loaded before Pydantic serialization - test_session_branches_api.py: add status assertion on fork response Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,7 @@ async def create_fork(
|
|||||||
)
|
)
|
||||||
|
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
await db.refresh(fork_point)
|
||||||
return ForkPointResponse.model_validate(fork_point)
|
return ForkPointResponse.model_validate(fork_point)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
from sqlalchemy import String, Text, DateTime, ForeignKey, Boolean, Integer, Enum as SAEnum
|
from sqlalchemy import String, Text, DateTime, ForeignKey, Boolean, Integer, Enum as SAEnum, text
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
||||||
from app.core.database import Base
|
from app.core.database import Base
|
||||||
@@ -64,13 +64,13 @@ class ScriptTemplate(Base):
|
|||||||
SAEnum("beginner", "intermediate", "advanced", name="script_complexity"), nullable=False, default="beginner"
|
SAEnum("beginner", "intermediate", "advanced", name="script_complexity"), nullable=False, default="beginner"
|
||||||
)
|
)
|
||||||
estimated_runtime: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
|
estimated_runtime: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
|
||||||
requires_elevation: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
requires_elevation: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("false"))
|
||||||
requires_modules: Mapped[list] = mapped_column(JSONB, nullable=False, default=list)
|
requires_modules: Mapped[list] = mapped_column(JSONB, nullable=False, default=list)
|
||||||
version: Mapped[int] = mapped_column(Integer, nullable=False, default=1)
|
version: Mapped[int] = mapped_column(Integer, nullable=False, default=1)
|
||||||
is_verified: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
is_verified: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||||
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
||||||
is_gallery_featured: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True)
|
is_gallery_featured: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("false"), index=True)
|
||||||
gallery_sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
gallery_sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text("0"))
|
||||||
usage_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
usage_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||||
created_at: Mapped[datetime] = mapped_column(
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ async def test_switch_branch(client: AsyncClient, test_user, auth_headers, test_
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
assert fork_resp.status_code == 201, fork_resp.text
|
||||||
fork_data = fork_resp.json()
|
fork_data = fork_resp.json()
|
||||||
branch_b_id = fork_data["options"][1]["branch_id"]
|
branch_b_id = fork_data["options"][1]["branch_id"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user