From a3833fd564c511f733acdfa7b2c37cbe6991c312 Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Thu, 5 May 2022 20:52:28 +0200 Subject: [PATCH] normalize newlines in sql functions before diffing for migration --- IHP/IDE/CodeGen/MigrationGenerator.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/IHP/IDE/CodeGen/MigrationGenerator.hs b/IHP/IDE/CodeGen/MigrationGenerator.hs index d5e07f01e..d5b99745f 100644 --- a/IHP/IDE/CodeGen/MigrationGenerator.hs +++ b/IHP/IDE/CodeGen/MigrationGenerator.hs @@ -346,7 +346,7 @@ normalizeStatement AddConstraint { tableName, constraint, deferrable, deferrable normalizeStatement CreateEnumType { name, values } = [ CreateEnumType { name = Text.toLower name, values = map Text.toLower values } ] normalizeStatement CreatePolicy { name, action, tableName, using, check } = [ CreatePolicy { name, tableName, using = normalizeExpression <$> using, check = normalizeExpression <$> check, action = normalizePolicyAction action } ] normalizeStatement CreateIndex { columns, indexType, .. } = [ CreateIndex { columns = map normalizeIndexColumn columns, indexType = normalizeIndexType indexType, .. } ] -normalizeStatement CreateFunction { .. } = [ CreateFunction { orReplace = False, language = Text.toUpper language, .. } ] +normalizeStatement CreateFunction { .. } = [ CreateFunction { orReplace = False, language = Text.toUpper language, functionBody = normalizeNewLines functionBody, .. } ] normalizeStatement otherwise = [otherwise] normalizePolicyAction (Just PolicyForAll) = Nothing @@ -625,3 +625,9 @@ normalizeIndexColumn IndexColumn { column, columnOrder } = normalizeIndexColumnOrder :: [IndexColumnOrder] -> [IndexColumnOrder] normalizeIndexColumnOrder columnOrder = columnOrder |> filter (/=Asc) + +normalizeNewLines :: Text -> Text +normalizeNewLines text = + text + |> Text.replace "\r\n" "\n" + |> Text.replace "\r" "\n" \ No newline at end of file