22 lines
756 B
Python
22 lines
756 B
Python
from sqlalchemy.dialects.postgresql import dialect, insert as pg_insert
|
|
from sqlalchemy import text
|
|
|
|
from core.storage.models import Artifact
|
|
|
|
|
|
def test_artifact_upsert_partial_index_predicate_is_literal():
|
|
statement = pg_insert(Artifact).values(
|
|
user_id="00000000-0000-0000-0000-000000000001",
|
|
origin_task_id="00000000-0000-0000-0000-000000000002",
|
|
current_path="task/report.docx",
|
|
label="report",
|
|
).on_conflict_do_update(
|
|
index_elements=[Artifact.user_id, Artifact.current_path],
|
|
index_where=text("status = 'active'"),
|
|
set_={"label": "report"},
|
|
)
|
|
|
|
sql = str(statement.compile(dialect=dialect()))
|
|
assert "WHERE status = 'active'" in sql
|
|
assert "WHERE status = %(" not in sql
|