persistent-2.17.1.0: Type-safe, multi-backend data serialization.

Safe Haskell | None
Language | Haskell2010

Database.Persist.Quasi.Internal

Contents

- UnboundEntityDef

Description

This `Internal` module may have breaking changes that will not be reflected in major version bumps. Please use Database.Persist.Quasi instead. If you need something in this module, please file an issue on GitHub.

Since: 2.13.0.0

Synopsis

- parse :: PersistSettings -> [(Maybe SourceLoc, Text)] -> CumulativeParseResult [UnboundEntityDef]
- data PersistSettings
- upperCaseSettings :: PersistSettings
- lowerCaseSettings :: PersistSettings
- data Attribute
  - = Assignment Text Text
  - | Parenthetical Text
  - | PText Text
  - | Quotation Text
- data SourceLoc = SourceLoc {
  - locFile :: Text
  - locStartLine :: Int
  - locStartCol :: Int
  }
- sourceLocFromTHLoc :: Loc -> SourceLoc
- parseFieldType :: Text -> Either String FieldType
- takeColsEx :: PersistSettings -> [Text] -> Maybe UnboundFieldDef
- type CumulativeParseResult a = (Set ParserWarning, Either [EntityParseError] a)
- renderErrors :: [EntityParseError] -> String
- parserWarningMessage :: ParserWarning -> String
- data UnboundEntityDef = UnboundEntityDef {
  - unboundForeignDefs :: [UnboundForeignDef]
  - unboundPrimarySpec :: PrimarySpec
  - unboundEntityDef :: EntityDef
  - unboundEntityFields :: [UnboundFieldDef]
  - unboundEntityDefSpan :: Maybe SourceSpan
  }
- getUnboundEntityNameHS :: UnboundEntityDef -> EntityNameHS
- unbindEntityDef :: EntityDef -> UnboundEntityDef
- getUnboundFieldDefs :: UnboundEntityDef -> [UnboundFieldDef]
- data UnboundForeignDef = UnboundForeignDef {
  - unboundForeignFields :: UnboundForeignFieldList
  - unboundForeignDef :: ForeignDef
  }
- getSqlNameOr :: FieldNameDB -> [FieldAttr] -> FieldNameDB
- data UnboundFieldDef = UnboundFieldDef {
  - unboundFieldNameHS :: FieldNameHS
  - unboundFieldNameDB :: FieldNameDB
  - unboundFieldAttrs :: [FieldAttr]
  - unboundFieldStrict :: Bool
  - unboundFieldType :: FieldType
  - unboundFieldCascade :: FieldCascade
  - unboundFieldGenerated :: Maybe Text
  - unboundFieldComments :: Maybe Text
  }
- data UnboundCompositeDef = UnboundCompositeDef {
  - unboundCompositeCols :: NonEmpty FieldNameHS
  - unboundCompositeAttrs :: [Attr]
  }
- data UnboundIdDef = UnboundIdDef {
  - unboundIdEntityName :: EntityNameHS
  - unboundIdDBName :: !FieldNameDB
  - unboundIdAttrs :: [FieldAttr]
  - unboundIdCascade :: FieldCascade
  - unboundIdType :: Maybe FieldType
  }
- unbindFieldDef :: FieldDef -> UnboundFieldDef
- isUnboundFieldNullable :: UnboundFieldDef -> IsNullable
- unboundIdDefToFieldDef :: FieldNameDB -> EntityNameHS -> UnboundIdDef -> FieldDef
- data PrimarySpec
  - = NaturalKey UnboundCompositeDef
  - | SurrogateKey UnboundIdDef
  - | DefaultKey FieldNameDB
- mkAutoIdField' :: FieldNameDB -> EntityNameHS -> SqlType -> FieldDef
- data UnboundForeignFieldList
  - = FieldListImpliedId (NonEmpty FieldNameHS)
  - | FieldListHasReferences (NonEmpty ForeignFieldReference)
- data ForeignFieldReference = ForeignFieldReference {
  - ffrSourceField :: FieldNameHS
  - ffrTargetField :: FieldNameHS
  }
- mkKeyConType :: EntityNameHS -> FieldType
- isHaskellUnboundField :: UnboundFieldDef -> Bool
- data FieldTypeLit
  - = IntTypeLit Integer
  - | TextTypeLit Text

# Documentation

parse :: PersistSettings -> [(Maybe SourceLoc, Text)] -> CumulativeParseResult [UnboundEntityDef] Source #

Parses a quasi-quoted syntax into a list of entity definitions.

data PersistSettings Source #

upperCaseSettings :: PersistSettings Source #

lowerCaseSettings :: PersistSettings Source #

data Attribute Source #

An attribute of an entity field definition or a directive.

Since: 2.17.1.0

Constructors

Assignment Text Text |
Parenthetical Text |
PText Text |
Quotation Text | Quoted field attributes are deprecated since 2.17.1.0.

#### Instances

Instances details

Show Attribute Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods showsPrec :: Int -> Attribute -> ShowS Source # show :: Attribute -> String Source # showList :: [Attribute] -> ShowS Source #
Eq Attribute Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods (==) :: Attribute -> Attribute -> Bool Source # (/=) :: Attribute -> Attribute -> Bool Source #
Ord Attribute Source # |

Instance details

Defined in Database.Persist.Quasi.Internal.ModelParser

Methods

compare :: Attribute -> Attribute -> Ordering Source #

(<) :: Attribute -> Attribute -> Bool Source #

(<=) :: Attribute -> Attribute -> Bool Source #

(>) :: Attribute -> Attribute -> Bool Source #

(>=) :: Attribute -> Attribute -> Bool Source #

max :: Attribute -> Attribute -> Attribute Source #

min :: Attribute -> Attribute -> Attribute Source #

data SourceLoc Source #

Source location: file and line/col information. This is half of a `SourceSpan`.

Since: 2.16.0.0

Constructors

SourceLoc |

Fields

- locFile :: Text
- locStartLine :: Int
- locStartCol :: Int

#### Instances

Instances details

Show SourceLoc Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods showsPrec :: Int -> SourceLoc -> ShowS Source # show :: SourceLoc -> String Source # showList :: [SourceLoc] -> ShowS Source #
Lift SourceLoc Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods lift :: Quote m => SourceLoc -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => SourceLoc -> Code m SourceLoc Source #

sourceLocFromTHLoc :: Loc -> SourceLoc Source #

parseFieldType :: Text -> Either String FieldType Source #

takeColsEx :: PersistSettings -> [Text] -> Maybe UnboundFieldDef Source #

type CumulativeParseResult a = (Set ParserWarning, Either [EntityParseError] a) Source #

Cumulative result of parsing multiple source texts.

Since: 2.16.0.0

renderErrors :: [EntityParseError] -> String Source #

Renders a list of EntityParseErrors as a String using `errorBundlePretty`, separated by line breaks. @since 2.16.0.0

parserWarningMessage :: ParserWarning -> String Source #

Uses `errorBundlePretty` to render a parser warning.

Since: 2.16.0.0

# UnboundEntityDef

data UnboundEntityDef Source #

An `EntityDef` produced by the QuasiQuoter. It contains information that the QuasiQuoter is capable of knowing about the entities. It is inherently unfinished, though - there are many other `Unbound` datatypes that also contain partial information.

The `unboundEntityDef` is not complete or reliable - to know which fields are safe to use, consult the parsing code.

This type was completely internal until 2.13.0.0, when it was exposed as part of the Database.Persist.Quasi.Internal module.

TODO: refactor this so we can expose it for consumers.

Since: 2.13.0.0

Constructors

UnboundEntityDef |

Fields

- unboundForeignDefs :: [UnboundForeignDef]

  A list of foreign definitions on the parsed entity.

  Since: 2.13.0.0

- unboundPrimarySpec :: PrimarySpec

  The specification for the primary key of the unbound entity.

  Since: 2.13.0.0

- unboundEntityDef :: EntityDef

  The incomplete and partial `EntityDef` that we're defining. We re-use the type here to prevent duplication, but several of the fields are unset and left to defaults.

  Since: 2.13.0.0

- unboundEntityFields :: [UnboundFieldDef]

  The list of fields for the entity. We're not capable of knowing information like "is this a reference?" or "what's the underlying type of the field?" yet, so we defer those to the Template Haskell execution.

  Since: 2.13.0.0

- unboundEntityDefSpan :: Maybe SourceSpan

  The source code span of this entity in the models file.

  Since: 2.15.0.0

#### Instances

Instances details

Show UnboundEntityDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods showsPrec :: Int -> UnboundEntityDef -> ShowS Source # show :: UnboundEntityDef -> String Source # showList :: [UnboundEntityDef] -> ShowS Source #
Eq UnboundEntityDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods (==) :: UnboundEntityDef -> UnboundEntityDef -> Bool Source # (/=) :: UnboundEntityDef -> UnboundEntityDef -> Bool Source #
Ord UnboundEntityDef Source # |

Instance details

Defined in Database.Persist.Quasi.Internal

Methods

compare :: UnboundEntityDef -> UnboundEntityDef -> Ordering Source #

(<) :: UnboundEntityDef -> UnboundEntityDef -> Bool Source #

(<=) :: UnboundEntityDef -> UnboundEntityDef -> Bool Source #

(>) :: UnboundEntityDef -> UnboundEntityDef -> Bool Source #

(>=) :: UnboundEntityDef -> UnboundEntityDef -> Bool Source #

max :: UnboundEntityDef -> UnboundEntityDef -> UnboundEntityDef Source #

min :: UnboundEntityDef -> UnboundEntityDef -> UnboundEntityDef Source #

Lift UnboundEntityDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods lift :: Quote m => UnboundEntityDef -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => UnboundEntityDef -> Code m UnboundEntityDef Source #

getUnboundEntityNameHS :: UnboundEntityDef -> EntityNameHS Source #

Return the `EntityNameHS` for an `UnboundEntityDef`.

Since: 2.13.0.0

unbindEntityDef :: EntityDef -> UnboundEntityDef Source #

Convert an `EntityDef` into an `UnboundEntityDef`. This "forgets" information about the `EntityDef`, but it is all kept present on the `unboundEntityDef` field if necessary.

Since: 2.13.0.0

getUnboundFieldDefs :: UnboundEntityDef -> [UnboundFieldDef] Source #

Returns the `[`UnboundFieldDef`]` for an `UnboundEntityDef`. This returns all fields defined on the entity.

Since: 2.13.0.0

data UnboundForeignDef Source #

Define an explicit foreign key reference.

    User
        name Text
        email Text

        Primary name email

    Dog
        ownerName Text
        ownerEmail Text

        Foreign User fk_dog_user ownerName ownerEmail

Since: 2.13.0.0

Constructors

UnboundForeignDef |

Fields

- unboundForeignFields :: UnboundForeignFieldList

  Fields in the source entity.

  Since: 2.13.0.0

- unboundForeignDef :: ForeignDef

  The `ForeignDef` which needs information filled in.

  This value is unreliable. See the parsing code to see what data is filled in here.

  Since: 2.13.0.0

#### Instances

Instances details

Show UnboundForeignDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods showsPrec :: Int -> UnboundForeignDef -> ShowS Source # show :: UnboundForeignDef -> String Source # showList :: [UnboundForeignDef] -> ShowS Source #
Eq UnboundForeignDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods (==) :: UnboundForeignDef -> UnboundForeignDef -> Bool Source # (/=) :: UnboundForeignDef -> UnboundForeignDef -> Bool Source #
Ord UnboundForeignDef Source # |

Instance details

Defined in Database.Persist.Quasi.Internal

Methods

compare :: UnboundForeignDef -> UnboundForeignDef -> Ordering Source #

(<) :: UnboundForeignDef -> UnboundForeignDef -> Bool Source #

(<=) :: UnboundForeignDef -> UnboundForeignDef -> Bool Source #

(>) :: UnboundForeignDef -> UnboundForeignDef -> Bool Source #

(>=) :: UnboundForeignDef -> UnboundForeignDef -> Bool Source #

max :: UnboundForeignDef -> UnboundForeignDef -> UnboundForeignDef Source #

min :: UnboundForeignDef -> UnboundForeignDef -> UnboundForeignDef Source #

Lift UnboundForeignDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods lift :: Quote m => UnboundForeignDef -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => UnboundForeignDef -> Code m UnboundForeignDef Source #

getSqlNameOr :: FieldNameDB -> [FieldAttr] -> FieldNameDB Source #

data UnboundFieldDef Source #

A representation of a database column, with everything that can be known at parse time.

Since: 2.13.0.0

Constructors

UnboundFieldDef |

Fields

- unboundFieldNameHS :: FieldNameHS

  The Haskell name of the field. This is parsed directly from the definition, and is used to generate the Haskell record field and the `EntityField` definition.

  Since: 2.13.0.0

- unboundFieldNameDB :: FieldNameDB

  The database name of the field. By default, this is determined by the `PersistSettings` record at parse time. You can customize this with a `sql=` attribute:

          name Text  sql=foo_name

  Since: 2.13.0.0

- unboundFieldAttrs :: [FieldAttr]

  The attributes present on the field. For rules on parsing and utility, see the comments on the datatype.

  Since: 2.13.0.0

- unboundFieldStrict :: Bool

  Whether or not the field should be strict in the generated Haskell code.

  Since: 2.13.0.0

- unboundFieldType :: FieldType

  The type of the field, as far as is known at parse time.

  The TemplateHaskell code will reconstruct a `Type` out of this, but the names will be imported as-is.

  Since: 2.13.0.0

- unboundFieldCascade :: FieldCascade

  We parse if there's a `FieldCascade` on the field. If the field is not a reference, this information is ignored.

      Post
         user UserId OnDeleteCascade

  Since: 2.13.0.0

- unboundFieldGenerated :: Maybe Text

  Contains an expression to generate the column. If this is present, then the column will not be written to the database, but generated by the expression every time.

      Item
          subtotal Int
          taxRate  Rational
          total    Int      generated="subtotal * tax_rate"

  Since: 2.13.0.0

- unboundFieldComments :: Maybe Text

  Any comments present on the field. Documentation comments use a Haskell-like syntax, and must be present before the field in question.

      Post
          -- | This is the blog post title.
          title Text
          -- | You can have multi-line comments.
          -- | But each line must have the pipe character.
          author UserId

  Since: 2.13.0.0

#### Instances

Instances details

Show UnboundFieldDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods showsPrec :: Int -> UnboundFieldDef -> ShowS Source # show :: UnboundFieldDef -> String Source # showList :: [UnboundFieldDef] -> ShowS Source #
Eq UnboundFieldDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods (==) :: UnboundFieldDef -> UnboundFieldDef -> Bool Source # (/=) :: UnboundFieldDef -> UnboundFieldDef -> Bool Source #
Ord UnboundFieldDef Source # |

Instance details

Defined in Database.Persist.Quasi.Internal

Methods

compare :: UnboundFieldDef -> UnboundFieldDef -> Ordering Source #

(<) :: UnboundFieldDef -> UnboundFieldDef -> Bool Source #

(<=) :: UnboundFieldDef -> UnboundFieldDef -> Bool Source #

(>) :: UnboundFieldDef -> UnboundFieldDef -> Bool Source #

(>=) :: UnboundFieldDef -> UnboundFieldDef -> Bool Source #

max :: UnboundFieldDef -> UnboundFieldDef -> UnboundFieldDef Source #

min :: UnboundFieldDef -> UnboundFieldDef -> UnboundFieldDef Source #

Lift UnboundFieldDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods lift :: Quote m => UnboundFieldDef -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => UnboundFieldDef -> Code m UnboundFieldDef Source #

data UnboundCompositeDef Source #

A definition for a composite primary key.

@since.2.13.0.0

Constructors

UnboundCompositeDef |

Fields

- unboundCompositeCols :: NonEmpty FieldNameHS

  The field names for the primary key.

  Since: 2.13.0.0

- unboundCompositeAttrs :: [Attr]

  A list of attributes defined on the primary key. This is anything that occurs after a `!` character.

  Since: 2.13.0.0

#### Instances

Instances details

Show UnboundCompositeDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods showsPrec :: Int -> UnboundCompositeDef -> ShowS Source # show :: UnboundCompositeDef -> String Source # showList :: [UnboundCompositeDef] -> ShowS Source #
Eq UnboundCompositeDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods (==) :: UnboundCompositeDef -> UnboundCompositeDef -> Bool Source # (/=) :: UnboundCompositeDef -> UnboundCompositeDef -> Bool Source #
Ord UnboundCompositeDef Source # |

Instance details

Defined in Database.Persist.Quasi.Internal

Methods

compare :: UnboundCompositeDef -> UnboundCompositeDef -> Ordering Source #

(<) :: UnboundCompositeDef -> UnboundCompositeDef -> Bool Source #

(<=) :: UnboundCompositeDef -> UnboundCompositeDef -> Bool Source #

(>) :: UnboundCompositeDef -> UnboundCompositeDef -> Bool Source #

(>=) :: UnboundCompositeDef -> UnboundCompositeDef -> Bool Source #

max :: UnboundCompositeDef -> UnboundCompositeDef -> UnboundCompositeDef Source #

min :: UnboundCompositeDef -> UnboundCompositeDef -> UnboundCompositeDef Source #

Lift UnboundCompositeDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods lift :: Quote m => UnboundCompositeDef -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => UnboundCompositeDef -> Code m UnboundCompositeDef Source #

data UnboundIdDef Source #

This type represents an `Id` declaration in the QuasiQuoted syntax.

    Id

This uses the implied settings, and is equivalent to omitting the `Id` statement entirely.

    Id Text

This will set the field type of the ID to be `Text`.

    Id Text sql=foo_id

This will set the field type of the Id to be `Text` and the SQL DB name to be `foo_id`.

    Id FooId

This results in a shared primary key - the `FooId` refers to a `Foo` table.

    Id FooId OnDelete Cascade

You can set a cascade behavior on an ID column.

Since: 2.13.0.0

Constructors

UnboundIdDef |

Fields

- unboundIdEntityName :: EntityNameHS
- unboundIdDBName :: !FieldNameDB
- unboundIdAttrs :: [FieldAttr]
- unboundIdCascade :: FieldCascade
- unboundIdType :: Maybe FieldType

#### Instances

Instances details

Show UnboundIdDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods showsPrec :: Int -> UnboundIdDef -> ShowS Source # show :: UnboundIdDef -> String Source # showList :: [UnboundIdDef] -> ShowS Source #
Eq UnboundIdDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods (==) :: UnboundIdDef -> UnboundIdDef -> Bool Source # (/=) :: UnboundIdDef -> UnboundIdDef -> Bool Source #
Ord UnboundIdDef Source # |

Instance details

Defined in Database.Persist.Quasi.Internal

Methods

compare :: UnboundIdDef -> UnboundIdDef -> Ordering Source #

(<) :: UnboundIdDef -> UnboundIdDef -> Bool Source #

(<=) :: UnboundIdDef -> UnboundIdDef -> Bool Source #

(>) :: UnboundIdDef -> UnboundIdDef -> Bool Source #

(>=) :: UnboundIdDef -> UnboundIdDef -> Bool Source #

max :: UnboundIdDef -> UnboundIdDef -> UnboundIdDef Source #

min :: UnboundIdDef -> UnboundIdDef -> UnboundIdDef Source #

Lift UnboundIdDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods lift :: Quote m => UnboundIdDef -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => UnboundIdDef -> Code m UnboundIdDef Source #

unbindFieldDef :: FieldDef -> UnboundFieldDef Source #

Forget innformation about a `FieldDef` so it can beused as an `UnboundFieldDef`.

Since: 2.13.0.0

isUnboundFieldNullable :: UnboundFieldDef -> IsNullable Source #

unboundIdDefToFieldDef :: FieldNameDB -> EntityNameHS -> UnboundIdDef -> FieldDef Source #

Convert an `UnboundIdDef` into a `FieldDef` suitable for use in the `EntityIdField` constructor.

Since: 2.13.0.0

data PrimarySpec Source #

The specification for how an entity's primary key should be formed.

Persistent requires that every table have a primary key. By default, an implied ID is assigned, based on the `mpsImplicitIdDef` field on `MkPersistSettings`. Because we can't access that type at parse-time, we defer that decision until later.

Since: 2.13.0.0

Constructors

NaturalKey UnboundCompositeDef

A `NaturalKey` contains columns that are defined on the datatype itself. This is defined using the `Primary` keyword and given a non-empty list of columns.

    User
        name    Text
        email   Text

        Primary name email

A natural key may also contain only a single column. A natural key with multiple columns is called a 'composite key'.

Since: 2.13.0.0

SurrogateKey UnboundIdDef

A surrogate key is not part of the domain model for a database table. You can specify a custom surro

You can specify a custom surrogate key using the `Id` syntax.

    User
        Id    Text
        name  Text

Note that you must provide a `default=` expression when using this in order to use `insert` or related functions. The `insertKey` function can be used instead, as it allows you to specify a key directly. Fixing this issue is tracked in #1247 on GitHub.

Since: 2.13.0.0

DefaultKey FieldNameDB | The default key for the entity using the settings in `MkPersistSettings`. This is implicit - a table without an `Id` or `Primary` declaration will have a `DefaultKey`. Since: 2.13.0.0

#### Instances

Instances details

Show PrimarySpec Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods showsPrec :: Int -> PrimarySpec -> ShowS Source # show :: PrimarySpec -> String Source # showList :: [PrimarySpec] -> ShowS Source #
Eq PrimarySpec Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods (==) :: PrimarySpec -> PrimarySpec -> Bool Source # (/=) :: PrimarySpec -> PrimarySpec -> Bool Source #
Ord PrimarySpec Source # |

Instance details

Defined in Database.Persist.Quasi.Internal

Methods

compare :: PrimarySpec -> PrimarySpec -> Ordering Source #

(<) :: PrimarySpec -> PrimarySpec -> Bool Source #

(<=) :: PrimarySpec -> PrimarySpec -> Bool Source #

(>) :: PrimarySpec -> PrimarySpec -> Bool Source #

(>=) :: PrimarySpec -> PrimarySpec -> Bool Source #

max :: PrimarySpec -> PrimarySpec -> PrimarySpec Source #

min :: PrimarySpec -> PrimarySpec -> PrimarySpec Source #

Lift PrimarySpec Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods lift :: Quote m => PrimarySpec -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => PrimarySpec -> Code m PrimarySpec Source #

mkAutoIdField' :: FieldNameDB -> EntityNameHS -> SqlType -> FieldDef Source #

data UnboundForeignFieldList Source #

A list of fields present on the foreign reference.

Constructors

FieldListImpliedId (NonEmpty FieldNameHS) | If no `References` keyword is supplied, then it is assumed that you are referring to the `Primary` key or `Id` of the target entity. Since: 2.13.0.0

FieldListHasReferences (NonEmpty ForeignFieldReference)

You can specify the exact columns you're referring to here, if they aren't part of a primary key. Most databases expect a unique index on the columns you refer to, but Persistent doesnt' check that.

    User
        Id           UUID default="uuid_generate_v1mc()"
        name         Text

        UniqueName name

    Dog
        ownerName    Text

        Foreign User fk_dog_user ownerName References name

Since: 2.13.0.0

#### Instances

Instances details

Show UnboundForeignFieldList Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods showsPrec :: Int -> UnboundForeignFieldList -> ShowS Source # show :: UnboundForeignFieldList -> String Source # showList :: [UnboundForeignFieldList] -> ShowS Source #
Eq UnboundForeignFieldList Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods (==) :: UnboundForeignFieldList -> UnboundForeignFieldList -> Bool Source # (/=) :: UnboundForeignFieldList -> UnboundForeignFieldList -> Bool Source #
Ord UnboundForeignFieldList Source # |

Instance details

Defined in Database.Persist.Quasi.Internal

Methods

compare :: UnboundForeignFieldList -> UnboundForeignFieldList -> Ordering Source #

(<) :: UnboundForeignFieldList -> UnboundForeignFieldList -> Bool Source #

(<=) :: UnboundForeignFieldList -> UnboundForeignFieldList -> Bool Source #

(>) :: UnboundForeignFieldList -> UnboundForeignFieldList -> Bool Source #

(>=) :: UnboundForeignFieldList -> UnboundForeignFieldList -> Bool Source #

max :: UnboundForeignFieldList -> UnboundForeignFieldList -> UnboundForeignFieldList Source #

min :: UnboundForeignFieldList -> UnboundForeignFieldList -> UnboundForeignFieldList Source #

Lift UnboundForeignFieldList Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods lift :: Quote m => UnboundForeignFieldList -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => UnboundForeignFieldList -> Code m UnboundForeignFieldList Source #

data ForeignFieldReference Source #

A pairing of the `FieldNameHS` for the source table to the `FieldNameHS` for the target table.

Since: 2.13.0.0

Constructors

ForeignFieldReference |

Fields

- ffrSourceField :: FieldNameHS

  The column on the source table.

  Since: 2.13.0.0

- ffrTargetField :: FieldNameHS

  The column on the target table.

  Since: 2.13.0.0

#### Instances

Instances details

Show ForeignFieldReference Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods showsPrec :: Int -> ForeignFieldReference -> ShowS Source # show :: ForeignFieldReference -> String Source # showList :: [ForeignFieldReference] -> ShowS Source #
Eq ForeignFieldReference Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods (==) :: ForeignFieldReference -> ForeignFieldReference -> Bool Source # (/=) :: ForeignFieldReference -> ForeignFieldReference -> Bool Source #
Ord ForeignFieldReference Source # |

Instance details

Defined in Database.Persist.Quasi.Internal

Methods

compare :: ForeignFieldReference -> ForeignFieldReference -> Ordering Source #

(<) :: ForeignFieldReference -> ForeignFieldReference -> Bool Source #

(<=) :: ForeignFieldReference -> ForeignFieldReference -> Bool Source #

(>) :: ForeignFieldReference -> ForeignFieldReference -> Bool Source #

(>=) :: ForeignFieldReference -> ForeignFieldReference -> Bool Source #

max :: ForeignFieldReference -> ForeignFieldReference -> ForeignFieldReference Source #

min :: ForeignFieldReference -> ForeignFieldReference -> ForeignFieldReference Source #

Lift ForeignFieldReference Source # |
Instance details Defined in Database.Persist.Quasi.Internal Methods lift :: Quote m => ForeignFieldReference -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => ForeignFieldReference -> Code m ForeignFieldReference Source #

mkKeyConType :: EntityNameHS -> FieldType Source #

Convert an `EntityNameHS` into `FieldType` that will get parsed into the ID type for the entity.

    >>> mkKeyConType (EntityNameHS "Hello)
    FTTypeCon Nothing HelloId

Since: 2.13.0.0

isHaskellUnboundField :: UnboundFieldDef -> Bool Source #

Returns `True` if the `UnboundFieldDef` does not have a `MigrationOnly` or `SafeToRemove` flag from the QuasiQuoter.

Since: 2.13.0.0

data FieldTypeLit Source #

Constructors

IntTypeLit Integer |
TextTypeLit Text |

#### Instances

Instances details

Read FieldTypeLit Source # |
Instance details Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS FieldTypeLit Source # readList :: ReadS [FieldTypeLit] Source # readPrec :: ReadPrec FieldTypeLit Source # readListPrec :: ReadPrec [FieldTypeLit] Source #
Show FieldTypeLit Source # |
Instance details Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> FieldTypeLit -> ShowS Source # show :: FieldTypeLit -> String Source # showList :: [FieldTypeLit] -> ShowS Source #
Eq FieldTypeLit Source # |
Instance details Defined in Database.Persist.Types.Base Methods (==) :: FieldTypeLit -> FieldTypeLit -> Bool Source # (/=) :: FieldTypeLit -> FieldTypeLit -> Bool Source #
Ord FieldTypeLit Source # |

Instance details

Defined in Database.Persist.Types.Base

Methods

compare :: FieldTypeLit -> FieldTypeLit -> Ordering Source #

(<) :: FieldTypeLit -> FieldTypeLit -> Bool Source #

(<=) :: FieldTypeLit -> FieldTypeLit -> Bool Source #

(>) :: FieldTypeLit -> FieldTypeLit -> Bool Source #

(>=) :: FieldTypeLit -> FieldTypeLit -> Bool Source #

max :: FieldTypeLit -> FieldTypeLit -> FieldTypeLit Source #

min :: FieldTypeLit -> FieldTypeLit -> FieldTypeLit Source #

Lift FieldTypeLit Source # |
Instance details Defined in Database.Persist.Types.Base Methods lift :: Quote m => FieldTypeLit -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => FieldTypeLit -> Code m FieldTypeLit Source #