git.iko.soy/typeable/postgresql-simple
on master help sign in
support jsonb type (from postgresql 9.4)

Note, that this patch was not generated by the script in tools.

commit01886cbdeab81122fc822ef61502c85753bff4a1 authorTobias Florek <tob@butter.sh> dateTue 19 Aug 2014, 14:20 (12 years ago) parent7a48e34
5 files changed+21−1
src/Database/PostgreSQL/Simple/BuiltinTypes.hs+8 src/Database/PostgreSQL/Simple/FromField.hs+1−1 src/Database/PostgreSQL/Simple/TypeInfo/Static.hs+10 tools/GenBuiltinTypes.hs+1 tools/GenTypeInfo.hs+1
src/Database/PostgreSQL/Simple/BuiltinTypes.hs+8
@@ -74,6 +74,7 @@ data BuiltinType
7474 | Void
7575 | UUID
7676 | JSON
77+ | JSONB
7778 deriving (Eq, Ord, Enum, Bounded, Read, Show, Typeable)
7879
7980builtin2oid :: BuiltinType -> PQ.Oid
@@ -125,6 +126,7 @@ builtin2oid typ = PQ.Oid $ case typ of
125126 Void -> 2278
126127 UUID -> 2950
127128 JSON -> 114
129+ JSONB -> 3802
128130
129131oid2builtin :: PQ.Oid -> Maybe BuiltinType
130132oid2builtin (PQ.Oid x) = case x of
@@ -175,6 +177,7 @@ oid2builtin (PQ.Oid x) = case x of
175177 2278 -> Just Void
176178 2950 -> Just UUID
177179 114 -> Just JSON
180+ 3802 -> Just JSONB
178181 _ -> Nothing
179182
180183builtin2typname :: BuiltinType -> ByteString
@@ -226,6 +229,7 @@ builtin2typname typ = case typ of
226229 Void -> void
227230 UUID -> uuid
228231 JSON -> json
232+ JSONB -> jsonb
229233
230234oid2typname :: PQ.Oid -> Maybe ByteString
231235oid2typname (PQ.Oid x) = case x of
@@ -276,6 +280,7 @@ oid2typname (PQ.Oid x) = case x of
276280 2278 -> Just void
277281 2950 -> Just uuid
278282 114 -> Just json
283+ 3802 -> Just jsonb
279284 _ -> Nothing
280285
281286bool :: ByteString
@@ -418,3 +423,6 @@ uuid = "uuid"
418423
419424json :: ByteString
420425json = "json"
426+
427+jsonb :: ByteString
428+jsonb = "jsonb"
src/Database/PostgreSQL/Simple/FromField.hs+1−1
@@ -492,7 +492,7 @@ instance FromField UUID where
492492-- | json
493493instance FromField JSON.Value where
494494 fromField f mbs =
495− if typeOid f /= $(inlineTypoid TI.json)
495+ if typeOid f /= $(inlineTypoid TI.json) && typeOid f /= $(inlineTypoid TI.jsonb)
496496 then returnError Incompatible f ""
497497 else case mbs of
498498 Nothing -> returnError UnexpectedNull f ""
src/Database/PostgreSQL/Simple/TypeInfo/Static.hs+10
@@ -65,6 +65,7 @@ module Database.PostgreSQL.Simple.TypeInfo.Static
6565 , void
6666 , uuid
6767 , json
68+ , jsonb
6869 ) where
6970
7071import Database.PostgreSQL.LibPQ (Oid(..))
@@ -119,6 +120,7 @@ staticTypeInfo (Oid x) = case x of
119120 2278 -> Just void
120121 2950 -> Just uuid
121122 114 -> Just json
123+ 3802 -> Just jsonb
122124 _ -> Nothing
123125
124126bool :: TypeInfo
@@ -496,3 +498,11 @@ json = Basic {
496498 typdelim = ',',
497499 typname = "json"
498500 }
501+
502+jsonb :: TypeInfo
503+jsonb = Basic {
504+ typoid = Oid 3802,
505+ typcategory = 'U',
506+ typdelim = ',',
507+ typname = "jsonb"
508+ }
tools/GenBuiltinTypes.hs+1
@@ -85,6 +85,7 @@ record
8585void
8686uuid UUID
8787json JSON
88+jsonb JSONB
8889|]
8990
9091instance IsString Blaze.Builder where
tools/GenTypeInfo.hs+1
@@ -127,6 +127,7 @@ record
127127void
128128uuid
129129json
130+jsonb
130131|]
131132
132133instance IsString Blaze.Builder where