rel8-internal
Safe HaskellNone
LanguageHaskell2010

Rel8.Internal.Table.Name

Synopsis

Documentation

namesFromLabels :: Table Name a => a Source #

Construct a table in the Name context containing the names of all columns. Nested column names will be combined with /, the resulting name will be truncated and a unique tag appended to the end of the name so that the resulting name has 63 or less characters (Postgres' default maximum column name length).

See also: namesFromLabelsTagged, namesFromLabelsWith.

namesFromLabelsTagged :: Table Name a => Tag -> a Source #

Similar to namesFromLabels, but receives an additional Tag to distinguish between relations. Resulting names will also have 63 or less characters.

namesFromLabelsWith :: Table Name a => (NonEmpty String -> String) -> a Source #

Construct a table in the Name context containing the names of all columns. The supplied function can be used to transform column names.

This function can be used to generically derive the columns for a TableSchema. For example,

myTableSchema :: TableSchema (MyTable Name)
myTableSchema = TableSchema
  { columns = namesFromLabelsWith last
  }

will construct a TableSchema where each columns names exactly corresponds to the name of the Haskell field.

namesFromLabelsWithA :: (Apply f, Table Name a) => (NonEmpty String -> f String) -> f a Source #

shortenName :: Maybe Tag -> NonEmpty String -> State Tag String Source #

Map a non-empty list of labels to a short SQL identifier with an opaleye tag appended, truncated if it would be too large.