Skip to content

Commit

Permalink
ParamReader instance is now provided by default for enum records (Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Aug 21, 2020
1 parent 6a99cb4 commit c6b92e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion IHP/SchemaCompiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ compileTypes options schema@(Schema statements) =
<> "import Database.PostgreSQL.Simple.FromRow\n"
<> "import Database.PostgreSQL.Simple.FromField hiding (Field, name)\n"
<> "import Database.PostgreSQL.Simple.ToField hiding (Field)\n"
<> "import IHP.Controller.Param ()\n"
<> "import qualified IHP.Controller.Param\n"
<> "import GHC.TypeLits\n"
<> "import Data.UUID (UUID)\n"
<> "import Data.Default\n"
Expand Down Expand Up @@ -275,6 +275,7 @@ compileEnumDataDefinitions enum@(CreateEnumType { name, values }) =
<> "instance Default " <> modelName <> " where def = " <> tableNameToModelName (unsafeHead values) <> "\n"
<> "instance ToField " <> modelName <> " where\n" <> indent (unlines (map compileToFieldInstanceForValue values))
<> "instance InputValue " <> modelName <> " where\n" <> indent (unlines (map compileInputValue values)) <> "\n"
<> "instance IHP.Controller.Param.ParamReader " <> modelName <> " where readParameter = IHP.Controller.Param.enumParamReader\n"
where
modelName = tableNameToModelName name
valueConstructors = map tableNameToModelName values
Expand Down

0 comments on commit c6b92e6

Please sign in to comment.