| Copyright | Flipstone Technology Partners 2023 |
|---|---|
| License | MIT |
| Stability | Stable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Orville.PostgreSQL.Schema.PrimaryKey
Description
Since: 1.0.0.0
Synopsis
- data PrimaryKey key
- primaryKeyDescription :: PrimaryKey key -> String
- primaryKeyFieldNames :: PrimaryKey key -> NonEmpty FieldName
- primaryKeyToSql :: PrimaryKey key -> key -> NonEmpty SqlValue
- primaryKey :: FieldDefinition NotNull key -> PrimaryKey key
- data PrimaryKeyPart key
- compositePrimaryKey :: PrimaryKeyPart key -> [PrimaryKeyPart key] -> PrimaryKey key
- primaryKeyPart :: (key -> part) -> FieldDefinition NotNull part -> PrimaryKeyPart key
- mapPrimaryKeyParts :: (forall part. (key -> part) -> FieldDefinition NotNull part -> a) -> PrimaryKey key -> NonEmpty a
- mkPrimaryKeyExpr :: PrimaryKey key -> PrimaryKeyExpr
- primaryKeyEquals :: PrimaryKey key -> key -> BooleanExpr
- primaryKeyIn :: PrimaryKey key -> NonEmpty key -> BooleanExpr
Documentation
data PrimaryKey key Source #
A Haskell description of the FieldDefinitions that make up the primary
key of a SQL table. This type supports composite primary keys as well
as singular ones.
Since: 1.0.0.0
primaryKeyDescription :: PrimaryKey key -> String Source #
primaryKeyDescription builds a user-readable representation of the
primary key for use in error messages and such. It is a comma-delimited
list of the names of the fields that make up the primary key.
Since: 1.0.0.0
primaryKeyFieldNames :: PrimaryKey key -> NonEmpty FieldName Source #
Retrieves the names of the fields that are part of the primary key.
Since: 1.0.0.0
primaryKeyToSql :: PrimaryKey key -> key -> NonEmpty SqlValue Source #
primaryKeyToSql converts a Haskell value for a primary key into the
(possibly multiple) SQL values that represent the primary key in the
database.
Since: 1.0.0.0
primaryKey :: FieldDefinition NotNull key -> PrimaryKey key Source #
primaryKey constructs a single-field primary key from the FieldDefinition
that corresponds to the primary key's column. This is generally used while
building a TableDefinition.
Since: 1.0.0.0
data PrimaryKeyPart key Source #
A PrimaryKeyPart describes one field of a composite primary key. Values
are built using primaryKeyPart and then used with compositePrimaryKey
to build a PrimaryKey.
Since: 1.0.0.0
compositePrimaryKey :: PrimaryKeyPart key -> [PrimaryKeyPart key] -> PrimaryKey key Source #
compositePrimaryKey constructs a multi-field primary key from the given
parts, each of which corresponds to one field in the primary key. You should
use this while building a TableDefinition for a table
that you want to have a multi-column primary key. See primaryKeyPart for
how to build the parts to be passed as parameters. Note: there is no special
significance to the first argument other than requiring that there is at
least one field in the primary key.
Since: 1.0.0.0
primaryKeyPart :: (key -> part) -> FieldDefinition NotNull part -> PrimaryKeyPart key Source #
primaryKeyPart constructs a building block for a composite primary key
based on a FieldDefinition and an accessor function to extract the value for
that field from the Haskell key type that represents the overall composite
key. PrimaryKeyPart values built using this function are usually then
passed in a list to compositePrimaryKey to build a PrimaryKey.
Since: 1.0.0.0
mapPrimaryKeyParts :: (forall part. (key -> part) -> FieldDefinition NotNull part -> a) -> PrimaryKey key -> NonEmpty a Source #
mapPrimaryKeyParts provides a way to access the innards of a PrimaryKey
definition to extract information. The given function will be called on
each part of the primary key in order and the list of results is returned.
Note that single-field and multi-field primary keys are treated the same by
this function, with the single-field case simply behaving as a composite key
with just one part.
Since: 1.0.0.0
mkPrimaryKeyExpr :: PrimaryKey key -> PrimaryKeyExpr Source #
Builds a PrimaryKeyExpr that is suitable to be used when creating
a table to define the primary key on the table.
Since: 1.0.0.0
primaryKeyEquals :: PrimaryKey key -> key -> BooleanExpr Source #
primaryKeyEquals builds a BooleanExpr that will match the row where
the primary key is equal to the given value. For single-field primary keys,
this is equivalent to fieldEquals, but primaryKeyEquals also handles
composite primary keys.
Since: 1.0.0.0
primaryKeyIn :: PrimaryKey key -> NonEmpty key -> BooleanExpr Source #
primaryKeyIn builds a BooleanExpr that will match rows where the
primary key is contained in the given list. For single-field primary keys,
this is equivalent to fieldIn, but primaryKeyIn also handles composite
primary keys.
Since: 1.0.0.0