git.iko.soy/typeable/postgresql-simple
on master help sign in
Fix docs relevant to the deprecation of BuiltinTypes
commit723f37e45736b35032354581cd9fe1f8d83c2951 authorLeon P Smith <leon@melding-monads.com> dateMon 19 Aug 2013, 20:30 (13 years ago) parent26d2b7a
3 files changed+17−13
src/Database/PostgreSQL/Simple/FromField.hs+11−9 src/Database/PostgreSQL/Simple/TypeInfo/Static.hs+3−2 tools/GenTypeInfo.hs+3−2
src/Database/PostgreSQL/Simple/FromField.hs+11−9
@@ -6,7 +6,7 @@
66{- |
77Module: Database.PostgreSQL.Simple.FromField
88Copyright: (c) 2011 MailRank, Inc.
9− (c) 2011-2012 Leon P Smith
9+ (c) 2011-2013 Leon P Smith
1010License: BSD3
1111Maintainer: Leon P Smith <leon@melding-monads.com>
1212Stability: experimental
@@ -31,13 +31,14 @@ might look like for a UUID type that implements the @Read@ class:
3131
3232@
3333import Data.UUID ( UUID )
34−import Database.PostgreSQL.Simple.BuiltinTypes
35− ( BuiltinType(UUID), builtin2oid )
34+import Database.PostgreSQL.Simple.FromField
35+ ( typeOid, returnError, ResultError(..) )
36+import Database.PostgreSQL.Simple.TypeInfo.Static (typoid, uuid)
3637import qualified Data.ByteString as B
3738
3839instance FromField UUID where
3940 fromField f mdata =
40− if typeOid f /= builtin2oid UUID
41+ if typeOid f /= typoid uuid
4142 then returnError Incompatible f \"\"
4243 else case B.unpack \`fmap\` mdata of
4344 Nothing -> returnError UnexpectedNull f \"\"
@@ -49,8 +50,9 @@ instance FromField UUID where
4950
5051Note that because PostgreSQL's @uuid@ type is built into postgres and is
5152not provided by an extension, the 'typeOid' of @uuid@ does not change and
52−thus we can examine it directly. Here, we simply pull the type oid out
53−of the static table provided by postgresql-simple.
53+thus we can examine it directly. One could hard-code the type oid, or
54+obtain it by other means, but in this case we simply pull it out of the
55+static table provided by postgresql-simple.
5456
5557On the other hand if the type is provided by an extension, such as
5658@PostGIS@ or @hstore@, then the 'typeOid' is not stable and can vary from
@@ -175,9 +177,9 @@ class FromField a where
175177--
176178-- More concretely, it returns the @typname@ column associated with the
177179-- type oid in the @pg_type@ table. First, postgresql-simple will check
178−-- built-in, static table. If the type oid is not there, postgresql-simple
179−-- will check a per-connection cache, and then finally query the database's
180−-- meta-schema.
180+-- the built-in, static table. If the type oid is not there,
181+-- postgresql-simple will check a per-connection cache, and then
182+-- finally query the database's meta-schema.
181183
182184typename :: Field -> Conversion ByteString
183185typename field = typname <$> typeInfo field
src/Database/PostgreSQL/Simple/TypeInfo/Static.hs+3−2
@@ -6,8 +6,9 @@
66-- Maintainer: Leon P Smith <leon@melding-monads.com>
77-- Stability: experimental
88--
9−-- Note that this module is semi-internal, and you probably want to use
10−-- Database.PostgreSQL.Simple.TypeInfo instead.
9+-- This module contains portions of the @pg_type@ table that are relevant
10+-- to postgresql-simple and are believed to not change between PostgreSQL
11+-- versions.
1112--
1213------------------------------------------------------------------------------
1314
tools/GenTypeInfo.hs+3−2
@@ -210,8 +210,9 @@ renderFile byOid byName names = ([longstring|
210210-- Maintainer: Leon P Smith <leon@melding-monads.com>
211211-- Stability: experimental
212212--
213−-- Note that this module is semi-internal, and you probably want to use
214−-- Database.PostgreSQL.Simple.TypeInfo instead.
213+-- This module contains portions of the @pg_type@ table that are relevant
214+-- to postgresql-simple and are believed to not change between PostgreSQL
215+-- versions.
215216--
216217------------------------------------------------------------------------------
217218