on dev help sign in
encode the bytes
4d7616eEitan Chatav
squeel-postgresql/src/Squeel/PostgreSQL/Binary2.hs+8−8
@@ -66,19 +66,19 @@ instance ToParam Value 'PGJson where toParam = K . Encoding.json_ast
66instance ToParam Value 'PGJsonb where toParam = K . Encoding.jsonb_ast
66instance ToParam Value 'PGJsonb where toParam = K . Encoding.jsonb_ast
67
67
68class ToColumnParam x (ty :: ColumnType) where
68class ToColumnParam x (ty :: ColumnType) where
69− toColumnParam :: x -> K (Maybe Encoding.Encoding) ty
69+ toColumnParam :: x -> K (Maybe Strict.ByteString) ty
70instance ToParam x pg => ToColumnParam x ('Required ('NotNull pg)) where
70instance ToParam x pg => ToColumnParam x ('Required ('NotNull pg)) where
71− toColumnParam = K . Just . unK . toParam @x @pg
71+ toColumnParam = K . Just . Encoding.encodingBytes . unK . toParam @x @pg
72instance ToParam x pg => ToColumnParam (Maybe x) ('Required ('Null pg)) where
72instance ToParam x pg => ToColumnParam (Maybe x) ('Required ('Null pg)) where
73− toColumnParam = K . fmap (unK . toParam @x @pg)
73+ toColumnParam = K . fmap (Encoding.encodingBytes . unK . toParam @x @pg)
74instance ToParam x pg => ToColumnParam (Maybe x) ('Optional (nullity pg)) where
74instance ToParam x pg => ToColumnParam (Maybe x) ('Optional (nullity pg)) where
75− toColumnParam = K . fmap (unK . toParam @x @pg)
75+ toColumnParam = K . fmap (Encoding.encodingBytes . unK . toParam @x @pg)
76
76
77class ToParams x (tys :: [ColumnType]) where
77class ToParams x (tys :: [ColumnType]) where
78− toParams :: x -> NP (K (Maybe Encoding.Encoding)) tys
78+ toParams :: x -> NP (K (Maybe Strict.ByteString)) tys
79 default toParams
79 default toParams
80 :: (IsProductType x xs, AllZip ToColumnParam xs tys)
80 :: (IsProductType x xs, AllZip ToColumnParam xs tys)
81− => x -> NP (K (Maybe Encoding.Encoding)) tys
81+ => x -> NP (K (Maybe Strict.ByteString)) tys
82 toParams
82 toParams
83 = htrans (Proxy @ToColumnParam) (toColumnParam . unI)
83 = htrans (Proxy @ToColumnParam) (toColumnParam . unI)
84 . unZ . unSOP . from
84 . unZ . unSOP . from
@@ -123,7 +123,7 @@ instance FromValue pg y
123 => FromColumnValue (column ::: ('Required ('NotNull pg))) y where
123 => FromColumnValue (column ::: ('Required ('NotNull pg))) y where
124 fromColumnValue = \case
124 fromColumnValue = \case
125 K Nothing -> error "fromColumnValue: saw NULL when expecting NOT NULL"
125 K Nothing -> error "fromColumnValue: saw NULL when expecting NOT NULL"
126− (K (Just bytes)) ->
126+ K (Just bytes) ->
127 let
127 let
128 errOrValue =
128 errOrValue =
129 Decoding.valueParser (fromValue @pg @y Proxy) bytes
129 Decoding.valueParser (fromValue @pg @y Proxy) bytes
@@ -146,4 +146,4 @@ class FromRow (columns :: [(Symbol,ColumnType)]) y where
146 => NP (K (Maybe Strict.ByteString)) columns -> y
146 => NP (K (Maybe Strict.ByteString)) columns -> y
147 fromRow
147 fromRow
148 = to . SOP . Z
148 = to . SOP . Z
149− . htrans (Proxy :: Proxy FromColumnValue) (I . fromColumnValue)
149+ . htrans (Proxy @FromColumnValue) (I . fromColumnValue)