Pretty much everything useful is in 0fae3bf's commit message:
The built-in 'readFile' function uses the system locale when determining
how to convert the input bytes to a Haskell 'String', which can be a
source of annoying and difficult to track down issues with respect to
character encoding.
Instead, it's safer to make the assumption that UTF-8 is the most
commonly used encoding scheme and reject all non-UTF-8 input as invalid
at compile-time whenever the 'sqlFromFile' splice is invoked.
It works as follows when run locally with echo 'CREATE DATABASE;' > test.sql and /bin/sh present:
Prelude Database.PG.Query> :set -XTemplateHaskell
Prelude Database.PG.Query>
Prelude Database.PG.Query> $(sqlFromFile "./test.sql")
Query {getQueryText = "CREATE DATABASE;\n"}
Prelude Database.PG.Query>
Prelude Database.PG.Query> $(sqlFromFile "/bin/sh")
<interactive>:3:1: error:
• Exception when trying to run compile-time code:
Cannot decode byte '\xdb': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream
Code: sqlFromFile "/bin/sh"
• In the untyped splice: $(sqlFromFile "/bin/sh")
Pretty much everything useful is in 0fae3bf's commit message:
It works as follows when run locally with
echo 'CREATE DATABASE;' > test.sql
and/bin/sh
present: