git.iko.soy/typeable/postgresql-simple
on master help sign in
Merge pull request #73 from Targen/json
9a11450Leon P Smith
src/Database/PostgreSQL/Simple/BuiltinTypes.hs+8
@@ -72,6 +72,7 @@ data BuiltinType
72 | Record
72 | Record
73 | Void
73 | Void
74 | UUID
74 | UUID
75+ | JSON
75 deriving (Eq, Ord, Enum, Bounded, Read, Show, Typeable)
76 deriving (Eq, Ord, Enum, Bounded, Read, Show, Typeable)
76
77
77builtin2oid :: BuiltinType -> PQ.Oid
78builtin2oid :: BuiltinType -> PQ.Oid
@@ -122,6 +123,7 @@ builtin2oid typ = PQ.Oid $ case typ of
122 Record -> 2249
123 Record -> 2249
123 Void -> 2278
124 Void -> 2278
124 UUID -> 2950
125 UUID -> 2950
126+ JSON -> 114
125
127
126oid2builtin :: PQ.Oid -> Maybe BuiltinType
128oid2builtin :: PQ.Oid -> Maybe BuiltinType
127oid2builtin (PQ.Oid x) = case x of
129oid2builtin (PQ.Oid x) = case x of
@@ -171,6 +173,7 @@ oid2builtin (PQ.Oid x) = case x of
171 2249 -> Just Record
173 2249 -> Just Record
172 2278 -> Just Void
174 2278 -> Just Void
173 2950 -> Just UUID
175 2950 -> Just UUID
176+ 114 -> Just JSON
174 _ -> Nothing
177 _ -> Nothing
175
178
176builtin2typname :: BuiltinType -> ByteString
179builtin2typname :: BuiltinType -> ByteString
@@ -221,6 +224,7 @@ builtin2typname typ = case typ of
221 Record -> record
224 Record -> record
222 Void -> void
225 Void -> void
223 UUID -> uuid
226 UUID -> uuid
227+ JSON -> json
224
228
225oid2typname :: PQ.Oid -> Maybe ByteString
229oid2typname :: PQ.Oid -> Maybe ByteString
226oid2typname (PQ.Oid x) = case x of
230oid2typname (PQ.Oid x) = case x of
@@ -270,6 +274,7 @@ oid2typname (PQ.Oid x) = case x of
270 2249 -> Just record
274 2249 -> Just record
271 2278 -> Just void
275 2278 -> Just void
272 2950 -> Just uuid
276 2950 -> Just uuid
277+ 114 -> Just json
273 _ -> Nothing
278 _ -> Nothing
274
279
275bool :: ByteString
280bool :: ByteString
@@ -409,3 +414,6 @@ void = "void"
409
414
410uuid :: ByteString
415uuid :: ByteString
411uuid = "uuid"
416uuid = "uuid"
417+
418+json :: ByteString
419+json = "json"
src/Database/PostgreSQL/Simple/TypeInfo/Static.hs+10
@@ -63,6 +63,7 @@ module Database.PostgreSQL.Simple.TypeInfo.Static
63 , record
63 , record
64 , void
64 , void
65 , uuid
65 , uuid
66+ , json
66 ) where
67 ) where
67
68
68import Database.PostgreSQL.LibPQ (Oid(..))
69import Database.PostgreSQL.LibPQ (Oid(..))
@@ -116,6 +117,7 @@ staticTypeInfo (Oid x) = case x of
116 2249 -> Just record
117 2249 -> Just record
117 2278 -> Just void
118 2278 -> Just void
118 2950 -> Just uuid
119 2950 -> Just uuid
120+ 114 -> Just json
119 _ -> Nothing
121 _ -> Nothing
120
122
121bool :: TypeInfo
123bool :: TypeInfo
@@ -485,3 +487,11 @@ uuid = Basic {
485 typdelim = ',',
487 typdelim = ',',
486 typname = "uuid"
488 typname = "uuid"
487 }
489 }
490+
491+json :: TypeInfo
492+json = Basic {
493+ typoid = Oid 114,
494+ typcategory = 'U',
495+ typdelim = ',',
496+ typname = "json"
497+ }
tools/GenBuiltinTypes.hs+1
@@ -84,6 +84,7 @@ refcursor RefCursor
84record
84record
85void
85void
86uuid UUID
86uuid UUID
87+json JSON
87|]
88|]
88
89
89instance IsString Blaze.Builder where
90instance IsString Blaze.Builder where
tools/GenTypeInfo.hs+2−1
@@ -67,7 +67,7 @@ data TypeInfo = TypeInfo
67
67
68instance FromRow TypeInfo where
68instance FromRow TypeInfo where
69 fromRow = TypeInfo <$> field <*> charF <*> charF <*> field <*> field
69 fromRow = TypeInfo <$> field <*> charF <*> charF <*> field <*> field
70− where charF = fieldWith (\_f dat -> Ok (B.head (unJust dat)))
70+ where charF = fieldWith (\_f dat -> return (B.head (unJust dat)))
71 unJust (Just x) = x
71 unJust (Just x) = x
72
72
73type NameMap = Map.Map B.ByteString TypeInfo
73type NameMap = Map.Map B.ByteString TypeInfo
@@ -128,6 +128,7 @@ refcursor
128record
128record
129void
129void
130uuid
130uuid
131+json
131|]
132|]
132
133
133instance IsString Blaze.Builder where
134instance IsString Blaze.Builder where