Open OndrejZapletal opened 5 years ago
Ondrej,
It is not normal for INHERITS to propagate uniqueness. You will have to explicitly apply uniqueness constraints to the inherited labels.
Please let me know whether this addresses your issue regarding inheritance. From the PostreSQL documentation at https://www.postgresql.org/docs/9.5/ddl-inherit.html
All check constraints and not-null constraints on a parent table are automatically inherited by its children, unless explicitly specified otherwise with NO INHERIT clauses.
Other types of constraints (unique, primary key, and foreign key constraints) are not inherited.
Thanks for the response, Joe. Your response addressed my concerns. It makes sense. I didn't realize that this also applies to PostgreSQL itself.
During my experimentation with AgensGraph, I came across a possible issue with constraint inheritance. It looks as if only
check_expr
is inherited.I've tried the following scenario:
Entity
label that hasuid
property that should be unique.NamedEntity
label that inherits fromEntity
and additionally has required propertyname
.NamedEntity
vertices with the sameuid
.What I would expect is an error due to a conflict of
uid
properties. When I try to createNamedEntity
vertex withoutuid
property, it correctly throwsERROR: new row for relation "namedentity" violates check constraint "Entity has uid"
.Following query throws
ERROR: conflicting key value violates exclusion constraint "NamedEntity uid is unique"
as expected:Is this behavior by design? Is the uniqueness constrained not inherited intentionally?
Agens version: AgensGraph 2.1.0, based on PostgreSQL 10.4