Backend tests run on SQLite by default (78 passed, 1 skipped); no Postgres needed
- conftest: default SHONAR_TEST_DATABASE_URL is a temp SQLite file, matching the bundled-lite engine; set the env var to a PG URL to exercise that path - models.py: add sqlite_where to the two partial unique indexes — without it SQLite built a FULL unique index on recording_id (WHERE not carried over), wrongly blocking a second export asset per recording - test_m9: pass UUID objects (not str) to direct ORM inserts/gets; SQLite's GUID bind processor rejects strings (asyncpg tolerated them) Verified: pytest -q = 78 passed, 1 skipped; ruff check clean
This commit is contained in:
parent
adc40201a1
commit
a94609c07b
3 changed files with 35 additions and 9 deletions
|
|
@ -26,6 +26,7 @@ from sqlalchemy import (
|
|||
String,
|
||||
Text,
|
||||
UniqueConstraint,
|
||||
text,
|
||||
)
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
|
@ -170,6 +171,7 @@ class Recording(Base, PublicIdMixin):
|
|||
"client_recording_id",
|
||||
unique=True,
|
||||
postgresql_where="client_recording_id IS NOT NULL",
|
||||
sqlite_where=text("client_recording_id IS NOT NULL"),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -204,11 +206,15 @@ class Asset(Base, PublicIdMixin):
|
|||
|
||||
__table_args__ = (
|
||||
# At most one immutable "original" per recording.
|
||||
# sqlite_where is required as well as postgresql_where: without it
|
||||
# SQLite gets a FULL unique index on recording_id (the WHERE clause
|
||||
# is not carried over), which wrongly blocks >1 export asset/recording.
|
||||
Index(
|
||||
"uq_assets_one_original",
|
||||
"recording_id",
|
||||
unique=True,
|
||||
postgresql_where="kind = 'original'",
|
||||
sqlite_where=text("kind = 'original'"),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue