From d9561e32dc32759126726e1e6d35c116a5470d24 Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Thu, 15 Oct 2020 11:28:42 +0200 Subject: [PATCH] Improved binary support --- IHP/ModelSupport.hs | 8 ++++++++ IHP/SchemaCompiler.hs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/IHP/ModelSupport.hs b/IHP/ModelSupport.hs index 61599ddd0..f3468685c 100644 --- a/IHP/ModelSupport.hs +++ b/IHP/ModelSupport.hs @@ -356,6 +356,14 @@ instance Default Day where instance Default UTCTime where def = UTCTime def 0 +instance Default (PG.Binary ByteString) where + def = PG.Binary "" + +instance Newtype.Newtype (PG.Binary payload) where + type O (PG.Binary payload) = payload + pack = PG.Binary + unpack (PG.Binary payload) = payload + class Record model where newRecord :: model diff --git a/IHP/SchemaCompiler.hs b/IHP/SchemaCompiler.hs index b2cb3759f..37db80c10 100644 --- a/IHP/SchemaCompiler.hs +++ b/IHP/SchemaCompiler.hs @@ -64,7 +64,7 @@ atomicType = \case PReal -> "Float" PDouble -> "Double" PDate -> "Data.Time.Calendar.Day" - PBinary -> "Binary" + PBinary -> "(Binary ByteString)" PTime -> "TimeOfDay" PCustomType theType -> tableNameToModelName theType PTimestamp -> "LocalTime"