Skip to content

Commit

Permalink
support createMany [] closes #627
Browse files Browse the repository at this point in the history
  • Loading branch information
fegu committed Dec 25, 2020
1 parent 11fb0e0 commit 16004c2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions IHP/SchemaCompiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ compileCreate table@(CreateTable { name, columns }) =
"create :: (?modelContext :: ModelContext) => " <> modelName <> " -> IO " <> modelName <> "\n"
<> "create model = do\n"
<> indent ("List.head <$> withDatabaseConnection \\databaseConnection -> Database.PostgreSQL.Simple.query databaseConnection \"INSERT INTO " <> name <> " (" <> columnNames <> ") VALUES (" <> values <> ") RETURNING *\" (" <> compileToRowValues bindings <> ")\n")
<> "createMany [] = pure []\n"
<> "createMany models = do\n"
<> indent ("withDatabaseConnection \\databaseConnection -> "
<> createManyQueryFn <> " databaseConnection (Query $ \"INSERT INTO " <> name <> " (" <> columnNames <> ") VALUES \" <> (ByteString.intercalate \", \" (List.map (\\_ -> \"(" <> values <> ")\") models)) <> \" RETURNING *\") " <> createManyFieldValues <> "\n"
Expand Down

0 comments on commit 16004c2

Please sign in to comment.