Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amitaibu committed Sep 2, 2024
1 parent 9d9c02c commit 9b9e976
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions ihp-ide/IHP/SchemaCompiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ compileTypeAlias table@(CreateTable { name, columns, inherits }) =
<> modelName
<> "' "
<> unwords (map (haskellType table) (variableAttributes table))
<> " "
<> unwords parentVariables
<> hasManyDefaults
<> "\n"
Expand All @@ -335,14 +334,19 @@ compileTypeAlias table@(CreateTable { name, columns, inherits }) =
|> unwords

parentVariables = case inherits of
Nothing -> []
Just parentTableName ->
case findTableByName parentTableName of
Just parentTable ->
let parentCreateTable = parentTable.unsafeGetCreateTable
in map (haskellType parentCreateTable) (variableAttributes parentCreateTable)
-- Satisfy the compiler.
Nothing -> error $ "Parent table " <> cs parentTableName <> " not found for table " <> cs name
Nothing -> []
Just parentTableName ->
case findTableByName parentTableName of
Just parentTable ->
let parentCreateTable = parentTable.unsafeGetCreateTable
parentTypes = map (haskellType parentCreateTable) (variableAttributes parentCreateTable)
in if null parentTypes
then []
else " " : parentTypes

-- Satisfy the compiler.
Nothing -> error $ "Parent table " <> cs parentTableName <> " not found for table " <> cs name



primaryKeyTypeName :: Text -> Text
Expand Down

0 comments on commit 9b9e976

Please sign in to comment.