Hoogle Search
Within LTS Haskell 24.41 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
newtype
EntityWithPrefix (prefix :: Symbol) recordpersistent Database.Persist.Sql This newtype wrapper is useful when selecting an entity out of the database and you want to provide a prefix to the table being selected. Consider this raw SQL query:
SELECT ?? FROM my_long_table_name AS mltn INNER JOIN other_table AS ot ON mltn.some_col = ot.other_col WHERE ...
We don't want to refer to my_long_table_name every time, so we create an alias. If we want to select it, we have to tell the raw SQL quasi-quoter that we expect the entity to be prefixed with some other name. We can give the above query a type with this, like:getStuff :: SqlPersistM [EntityWithPrefix "mltn" MyLongTableName] getStuff = rawSql queryText []
The EntityWithPrefix bit is a boilerplate newtype wrapper, so you can remove it with unPrefix, like this:getStuff :: SqlPersistM [Entity MyLongTableName] getStuff = unPrefix @"mltn" <$> rawSql queryText []
The symbol is a "type application" and requires the TypeApplications@ language extension.EntityWithPrefix :: Entity record -> EntityWithPrefix (prefix :: Symbol) recordpersistent Database.Persist.Sql No documentation available.
-
persistent Database.Persist.Sql Used when determining how to prefix a column name in a WHERE clause.
PrefixExcluded :: FilterTablePrefixpersistent Database.Persist.Sql Prefix the column name with the EXCLUDED keyword. This is used with the Postgresql backend when doing ON CONFLICT DO UPDATE clauses - see the documentation on upsertWhere and upsertManyWhere.
PrefixTableName :: FilterTablePrefixpersistent Database.Persist.Sql Prefix the column with the table name. This is useful if the column name might be ambiguous.
unEntityWithPrefix :: EntityWithPrefix (prefix :: Symbol) record -> Entity recordpersistent Database.Persist.Sql No documentation available.
unPrefix :: forall (prefix :: Symbol) record . EntityWithPrefix prefix record -> Entity recordpersistent Database.Persist.Sql A helper function to tell GHC what the EntityWithPrefix prefix should be. This allows you to use a type application to specify the prefix, instead of specifying the etype on the result. As an example, here's code that uses this:
myQuery :: SqlPersistM [Entity Person] myQuery = fmap (unPrefix @"p") $ rawSql query [] where query = "SELECT ?? FROM person AS p"
mpsPrefixFields :: MkPersistSettings -> Boolpersistent Database.Persist.TH Prefix field names with the model name. Default: True. Note: this field is deprecated. Use the mpsFieldLabelModifier and mpsConstraintLabelModifier instead.
mpsPrefixFields :: MkPersistSettings -> Boolpersistent Database.Persist.TH.Internal Prefix field names with the model name. Default: True. Note: this field is deprecated. Use the mpsFieldLabelModifier and mpsConstraintLabelModifier instead.
InfixConstructor :: ConstructorVariantth-abstraction Language.Haskell.TH.Datatype Constructor without field names that is declared infix