You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
before() function in post-update policy rules fails with PostgreSQL native enums — operator does not exist: text <> "EnumType" #2727
Description and expected behavior
When using before() in @@deny("post-update", ...) policy rules to compare a PostgreSQL enum field's previous value against its current value, the generated SQL casts the $before values as text. PostgreSQL rejects the comparison because the column is a native enum type and there's no implicit <> operator between text and a custom enum.
Error: 42883 — operator does not exist: text <> "StateType"
Reproduction:
enum StateType {
PREAMBLE
IN_PROGRESS
DONE
REVIEWED
}
model Post {
id String @id @default(uuid())
state StateType @default(PREAMBLE)
@@deny("post-update", before().state != state && (
before().state == PREAMBLE && state != IN_PROGRESS ||
before().state == IN_PROGRESS && state != DONE && state != PREAMBLE ||
before().state == DONE && state != REVIEWED ||
before().state == REVIEWED && state != DONE))
}
Generated SQL (problematic part):
select COUNT(1) = $1 as "$condition"
from "public"."Assessment"
left join (
select cast("$values"."column1" as uuid) as "id",
cast("$values"."column2" as text) as "state" -- ← cast as text, should be "StateType"
from (VALUES ($2, $3)) as "$values"
) as "$before" on "Assessment"."id" = "$before"."id"
where "Assessment"."id" = $4
and coalesce("$before"."state" != "Assessment"."state" and (...), false) = false
-- ^^^^ text ^^^^ "StateType" enum → operator does not exist
Environment (please complete the following information):
Activity
ymc9 commentedon Oct 27, 2026
Released in v3.10.0 via #2869.