git.iko.soy/typeable/postgresql-simple
on master help sign in
Renamed Data Constructors (mostly from builtin types)

Database.PostgreSQL.Simple.BuiltinTypes Bytea -> ByteA Regproc -> RegProc Lseg -> LSeg Abstime -> AbsTime Reltime -> RelTime Tinterval -> TInterval Macaddr -> MacAddr Bpchar -> BpChar Varchar -> VarChar TimestampWithTimeZone -> TimestampTZ TimeWithTimezone -> TimeTZ Varbit -> VarBit Refcursor -> RefCursor Database.PostgreSQL.Simple.ToField escapeBytea -> escapeByteA

commit7687a3eedb72ba66cab32f5c63867a1a1443a932 authorLeon P Smith <leon@melding-monads.com> dateMon 18 Jun 2012, 22:00 (14 years ago) parentf991193
4 files changed+131−131
src/Database/PostgreSQL/Simple.hs+2−2 src/Database/PostgreSQL/Simple/BuiltinTypes.hs+117−117 src/Database/PostgreSQL/Simple/FromField.hs+8−8 src/Database/PostgreSQL/Simple/ToField.hs+4−4
src/Database/PostgreSQL/Simple.hs+2−2
@@ -310,7 +310,7 @@ buildQuery conn q template xs = zipParams (split template) <$> mapM sub xs
310310 utf8ToString = T.unpack . TE.decodeUtf8
311311 sub (Plain b) = pure b
312312 sub (Escape s) = quote <$> escapeStringConn conn s
313− sub (EscapeBytea s) = quote <$> escapeByteaConn conn s
313+ sub (EscapeByteA s) = quote <$> escapeByteaConn conn s
314314 sub (Many ys) = mconcat <$> mapM sub ys
315315 split s = fromByteString h : if B.null t then [] else split (B.tail t)
316316 where (h,t) = B.break (=='?') s
@@ -678,7 +678,7 @@ fmtError msg q xs = throw FormatError {
678678 }
679679 where twiddle (Plain b) = toByteString b
680680 twiddle (Escape s) = s
681− twiddle (EscapeBytea s) = s
681+ twiddle (EscapeByteA s) = s
682682 twiddle (Many ys) = B.concat (map twiddle ys)
683683
684684-- $use
src/Database/PostgreSQL/Simple/BuiltinTypes.hs+117−117
@@ -3,7 +3,7 @@
33------------------------------------------------------------------------------
44-- |
55-- Module: Database.PostgreSQL.Simple.BuiltinTypes
6−-- Copyright: (c) 2011 Leon P Smith
6+-- Copyright: (c) 2011-2012 Leon P Smith
77-- License: BSD3
88-- Maintainer: Leon P Smith <leon@melding-monads.com>
99-- Stability: experimental
@@ -27,13 +27,13 @@ import qualified Database.PostgreSQL.LibPQ as PQ
2727
2828data BuiltinType
2929 = Bool
30− | Bytea
30+ | ByteA
3131 | Char
3232 | Name
3333 | Int8
3434 | Int2
3535 | Int4
36− | Regproc
36+ | RegProc
3737 | Text
3838 | Oid
3939 | Tid
@@ -41,7 +41,7 @@ data BuiltinType
4141 | Cid
4242 | Xml
4343 | Point
44− | Lseg
44+ | LSeg
4545 | Path
4646 | Box
4747 | Polygon
@@ -49,88 +49,88 @@ data BuiltinType
4949 | Cidr
5050 | Float4
5151 | Float8
52− | Abstime
53− | Reltime
54− | Tinterval
52+ | AbsTime
53+ | RelTime
54+ | TInterval
5555 | Unknown
5656 | Circle
5757 | Money
58− | Macaddr
58+ | MacAddr
5959 | Inet
60− | Bpchar
61− | Varchar
60+ | BpChar
61+ | VarChar
6262 | Date
6363 | Time
6464 | Timestamp
65− | TimestampWithTimeZone
65+ | TimestampTZ
6666 | Interval
67− | TimeWithTimeZone
67+ | TimeTZ
6868 | Bit
69− | Varbit
69+ | VarBit
7070 | Numeric
71− | Refcursor
71+ | RefCursor
7272 | Record
7373 | Void
7474 deriving (Eq, Ord, Enum, Bounded, Read, Show, Typeable)
7575
7676builtin2oid :: BuiltinType -> PQ.Oid
7777builtin2oid typ = PQ.Oid $ case typ of
78− Bool -> 16
79− Bytea -> 17
80− Char -> 18
81− Name -> 19
82− Int8 -> 20
83− Int2 -> 21
84− Int4 -> 23
85− Regproc -> 24
86− Text -> 25
87− Oid -> 26
88− Tid -> 27
89− Xid -> 28
90− Cid -> 29
91− Xml -> 142
92− Point -> 600
93− Lseg -> 601
94− Path -> 602
95− Box -> 603
96− Polygon -> 604
97− Line -> 628
98− Cidr -> 650
99− Float4 -> 700
100− Float8 -> 701
101− Abstime -> 702
102− Reltime -> 703
103− Tinterval -> 704
104− Unknown -> 705
105− Circle -> 718
106− Money -> 790
107− Macaddr -> 829
108− Inet -> 869
109− Bpchar -> 1042
110− Varchar -> 1043
111− Date -> 1082
112− Time -> 1083
113− Timestamp -> 1114
114− TimestampWithTimeZone -> 1184
115− Interval -> 1186
116− TimeWithTimeZone -> 1266
117− Bit -> 1560
118− Varbit -> 1562
119− Numeric -> 1700
120− Refcursor -> 1790
121− Record -> 2249
122− Void -> 2278
78+ Bool -> 16
79+ ByteA -> 17
80+ Char -> 18
81+ Name -> 19
82+ Int8 -> 20
83+ Int2 -> 21
84+ Int4 -> 23
85+ RegProc -> 24
86+ Text -> 25
87+ Oid -> 26
88+ Tid -> 27
89+ Xid -> 28
90+ Cid -> 29
91+ Xml -> 142
92+ Point -> 600
93+ LSeg -> 601
94+ Path -> 602
95+ Box -> 603
96+ Polygon -> 604
97+ Line -> 628
98+ Cidr -> 650
99+ Float4 -> 700
100+ Float8 -> 701
101+ AbsTime -> 702
102+ RelTime -> 703
103+ TInterval -> 704
104+ Unknown -> 705
105+ Circle -> 718
106+ Money -> 790
107+ MacAddr -> 829
108+ Inet -> 869
109+ BpChar -> 1042
110+ VarChar -> 1043
111+ Date -> 1082
112+ Time -> 1083
113+ Timestamp -> 1114
114+ TimestampTZ -> 1184
115+ Interval -> 1186
116+ TimeTZ -> 1266
117+ Bit -> 1560
118+ VarBit -> 1562
119+ Numeric -> 1700
120+ RefCursor -> 1790
121+ Record -> 2249
122+ Void -> 2278
123123
124124oid2builtin :: PQ.Oid -> Maybe BuiltinType
125125oid2builtin (PQ.Oid x) = case x of
126126 16 -> Just Bool
127− 17 -> Just Bytea
127+ 17 -> Just ByteA
128128 18 -> Just Char
129129 19 -> Just Name
130130 20 -> Just Int8
131131 21 -> Just Int2
132132 23 -> Just Int4
133− 24 -> Just Regproc
133+ 24 -> Just RegProc
134134 25 -> Just Text
135135 26 -> Just Oid
136136 27 -> Just Tid
@@ -138,7 +138,7 @@ oid2builtin (PQ.Oid x) = case x of
138138 29 -> Just Cid
139139 142 -> Just Xml
140140 600 -> Just Point
141− 601 -> Just Lseg
141+ 601 -> Just LSeg
142142 602 -> Just Path
143143 603 -> Just Box
144144 604 -> Just Polygon
@@ -146,77 +146,77 @@ oid2builtin (PQ.Oid x) = case x of
146146 650 -> Just Cidr
147147 700 -> Just Float4
148148 701 -> Just Float8
149− 702 -> Just Abstime
150− 703 -> Just Reltime
151− 704 -> Just Tinterval
149+ 702 -> Just AbsTime
150+ 703 -> Just RelTime
151+ 704 -> Just TInterval
152152 705 -> Just Unknown
153153 718 -> Just Circle
154154 790 -> Just Money
155− 829 -> Just Macaddr
155+ 829 -> Just MacAddr
156156 869 -> Just Inet
157− 1042 -> Just Bpchar
158− 1043 -> Just Varchar
157+ 1042 -> Just BpChar
158+ 1043 -> Just VarChar
159159 1082 -> Just Date
160160 1083 -> Just Time
161161 1114 -> Just Timestamp
162− 1184 -> Just TimestampWithTimeZone
162+ 1184 -> Just TimestampTZ
163163 1186 -> Just Interval
164− 1266 -> Just TimeWithTimeZone
164+ 1266 -> Just TimeTZ
165165 1560 -> Just Bit
166− 1562 -> Just Varbit
166+ 1562 -> Just VarBit
167167 1700 -> Just Numeric
168− 1790 -> Just Refcursor
168+ 1790 -> Just RefCursor
169169 2249 -> Just Record
170170 2278 -> Just Void
171171 _ -> Nothing
172172
173173builtin2typname :: BuiltinType -> ByteString
174174builtin2typname typ = case typ of
175− Bool -> bool
176− Bytea -> bytea
177− Char -> char
178− Name -> name
179− Int8 -> int8
180− Int2 -> int2
181− Int4 -> int4
182− Regproc -> regproc
183− Text -> text
184− Oid -> oid
185− Tid -> tid
186− Xid -> xid
187− Cid -> cid
188− Xml -> xml
189− Point -> point
190− Lseg -> lseg
191− Path -> path
192− Box -> box
193− Polygon -> polygon
194− Line -> line
195− Cidr -> cidr
196− Float4 -> float4
197− Float8 -> float8
198− Abstime -> abstime
199− Reltime -> reltime
200− Tinterval -> tinterval
201− Unknown -> unknown
202− Circle -> circle
203− Money -> money
204− Macaddr -> macaddr
205− Inet -> inet
206− Bpchar -> bpchar
207− Varchar -> varchar
208− Date -> date
209− Time -> time
210− Timestamp -> timestamp
211− TimestampWithTimeZone -> timestamptz
212− Interval -> interval
213− TimeWithTimeZone -> timetz
214− Bit -> bit
215− Varbit -> varbit
216− Numeric -> numeric
217− Refcursor -> refcursor
218− Record -> record
219− Void -> void
175+ Bool -> bool
176+ ByteA -> bytea
177+ Char -> char
178+ Name -> name
179+ Int8 -> int8
180+ Int2 -> int2
181+ Int4 -> int4
182+ RegProc -> regproc
183+ Text -> text
184+ Oid -> oid
185+ Tid -> tid
186+ Xid -> xid
187+ Cid -> cid
188+ Xml -> xml
189+ Point -> point
190+ LSeg -> lseg
191+ Path -> path
192+ Box -> box
193+ Polygon -> polygon
194+ Line -> line
195+ Cidr -> cidr
196+ Float4 -> float4
197+ Float8 -> float8
198+ AbsTime -> abstime
199+ RelTime -> reltime
200+ TInterval -> tinterval
201+ Unknown -> unknown
202+ Circle -> circle
203+ Money -> money
204+ MacAddr -> macaddr
205+ Inet -> inet
206+ BpChar -> bpchar
207+ VarChar -> varchar
208+ Date -> date
209+ Time -> time
210+ Timestamp -> timestamp
211+ TimestampTZ -> timestamptz
212+ Interval -> interval
213+ TimeTZ -> timetz
214+ Bit -> bit
215+ VarBit -> varbit
216+ Numeric -> numeric
217+ RefCursor -> refcursor
218+ Record -> record
219+ Void -> void
220220
221221oid2typname :: PQ.Oid -> Maybe ByteString
222222oid2typname (PQ.Oid x) = case x of
src/Database/PostgreSQL/Simple/FromField.hs+8−8
@@ -160,7 +160,7 @@ unBinary :: Binary t -> t
160160unBinary (Binary x) = x
161161
162162instance FromField SB.ByteString where
163− fromField f dat = if typeOid f == builtin2oid Bytea
163+ fromField f dat = if typeOid f == builtin2oid ByteA
164164 then unBinary <$> fromField f dat
165165 else doFromField f okText' (pure . B.copy) dat
166166
@@ -195,10 +195,10 @@ instance FromField [Char] where
195195 fromField f dat = ST.unpack <$> fromField f dat
196196
197197instance FromField UTCTime where
198− fromField = ff TimestampWithTimeZone "UTCTime" parseUTCTime
198+ fromField = ff TimestampTZ "UTCTime" parseUTCTime
199199
200200instance FromField ZonedTime where
201− fromField = ff TimestampWithTimeZone "ZonedTime" parseZonedTime
201+ fromField = ff TimestampTZ "ZonedTime" parseZonedTime
202202
203203instance FromField LocalTime where
204204 fromField = ff Timestamp "LocalTime" parseLocalTime
@@ -210,10 +210,10 @@ instance FromField TimeOfDay where
210210 fromField = ff Time "TimeOfDay" parseTimeOfDay
211211
212212instance FromField UTCTimestamp where
213− fromField = ff TimestampWithTimeZone "UTCTimestamp" parseUTCTimestamp
213+ fromField = ff TimestampTZ "UTCTimestamp" parseUTCTimestamp
214214
215215instance FromField ZonedTimestamp where
216− fromField = ff TimestampWithTimeZone "ZonedTimestamp" parseZonedTimestamp
216+ fromField = ff TimestampTZ "ZonedTimestamp" parseZonedTimestamp
217217
218218instance FromField LocalTimestamp where
219219 fromField = ff Timestamp "LocalTimestamp" parseLocalTimestamp
@@ -251,9 +251,9 @@ compat :: Compat -> Compat -> Bool
251251compat (Compat a) (Compat b) = a .&. b /= 0
252252
253253okText, okText', okBinary, ok16, ok32, ok64, okInt :: Compat
254−okText = mkCompats [Name,Text,Char,Bpchar,Varchar]
255−okText' = mkCompats [Name,Text,Char,Bpchar,Varchar,Unknown]
256−okBinary = mkCompats [Bytea]
254+okText = mkCompats [Name,Text,Char,BpChar,VarChar]
255+okText' = mkCompats [Name,Text,Char,BpChar,VarChar,Unknown]
256+okBinary = mkCompats [ByteA]
257257ok16 = mkCompats [Int2]
258258ok32 = mkCompats [Int2,Int4]
259259ok64 = mkCompats [Int2,Int4,Int8]
src/Database/PostgreSQL/Simple/ToField.hs+4−4
@@ -53,7 +53,7 @@ data Action =
5353 -- ^ Escape and enclose in quotes before substituting. Use for all
5454 -- text-like types, and anything else that may contain unsafe
5555 -- characters when rendered.
56− | EscapeBytea ByteString
56+ | EscapeByteA ByteString
5757 -- ^ Escape binary data for use as a @bytea@ literal. Include surrounding
5858 -- quotes. This is used by the 'Binary' newtype wrapper.
5959 | Many [Action]
@@ -63,7 +63,7 @@ data Action =
6363instance Show Action where
6464 show (Plain b) = "Plain " ++ show (toByteString b)
6565 show (Escape b) = "Escape " ++ show b
66− show (EscapeBytea b) = "EscapeBytea " ++ show b
66+ show (EscapeByteA b) = "EscapeByteA " ++ show b
6767 show (Many b) = "Many " ++ show b
6868
6969-- | A type that may be used as a single parameter to a SQL query.
@@ -158,11 +158,11 @@ instance ToField Double where
158158 {-# INLINE toField #-}
159159
160160instance ToField (Binary SB.ByteString) where
161− toField (Binary bs) = EscapeBytea bs
161+ toField (Binary bs) = EscapeByteA bs
162162 {-# INLINE toField #-}
163163
164164instance ToField (Binary LB.ByteString) where
165− toField (Binary bs) = (EscapeBytea . SB.concat . LB.toChunks) bs
165+ toField (Binary bs) = (EscapeByteA . SB.concat . LB.toChunks) bs
166166 {-# INLINE toField #-}
167167
168168instance ToField SB.ByteString where