graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.Backends.Postgres.Schema.OnConflict

Description

Postgres Schema OnConflict

This module contains the building blocks for parsing on_conflict clauses, which in the Postgres backend are used to implement upsert functionality. These are used by backendInsertParser to construct a postgres-specific schema parser for insert (and upsert) mutations.

Synopsis

Documentation

onConflictFieldParser :: forall pgKind r m n. (MonadBuildSchema ('Postgres pgKind) r m n, AggregationPredicatesSchema ('Postgres pgKind)) => TableInfo ('Postgres pgKind) -> SchemaT r m (InputFieldsParser n (Maybe (OnConflictClause ('Postgres pgKind) (UnpreparedValue ('Postgres pgKind))))) Source #

Parser for a field name on_conflict of type tablename_on_conflict.

The tablename_on_conflict object is used to generate the ON CONFLICT SQL clause, indicating what should be done if an insert raises a conflict.

The types ordinarily produced by this parser are only created if the table has unique or primary keys constraints.

If there are no columns for which the current role has update permissions, we must still accept an empty list for update_columns to support the "ON CONFLICT DO NOTHING" case. We do this by adding a placeholder value to the enum. See https://github.com/hasura/graphql-engine/issues/6804.