lpsmith / postgresql-simple

Mid-level client library for accessing PostgreSQL from Haskell
Other
206 stars 71 forks source link

Silently fails when using a string with a null character #223

Open enolan opened 7 years ago

enolan commented 7 years ago

Postgres can't handle strings with \0 in them. However, they are valid Haskell Text and String values. If you pass one to a postgres-simple query, the string will be silently truncated after the null.

Prelude Database.PostgreSQL.Simple Data.Text> execute conn "insert into program (name, environment) values (?,?);" ("this string \0 is cut off","echo")
1
Prelude Database.PostgreSQL.Simple Data.Text> query_ conn "select * from program" :: IO ([(Int, Text, Text)])
[(7,"this string ","echo")]

I'm not sure the best way to handle this. The simplest thing is to throw an exception.

saurabhnanda commented 6 years ago

Possibly related to #218 ?