Skip to content

Commit 07f8843

Browse files
committed
More documentation tweaks
1 parent 14e7b43 commit 07f8843

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/Database/PostgreSQL/Simple/Types.hs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,17 @@ newtype Only a = Only {
143143
-- case:
144144
--
145145
-- > query c "select * from whatever where coalesce(id NOT in ?, TRUE)"
146-
-- > (Only (In ([] :: [Int])))
146+
-- > (Only (In [] :: In [Int]))
147147
--
148148
-- > query c "select * from whatever where coalesce(id IN ?, FALSE)"
149-
-- > (Only (In ([] :: [Int])))
150-
--
151-
-- Note that at as of PostgreSQL 9.4 at least, the query planner cannot
152-
-- see inside the @COALESCE@ operator, so if you have an index on @id@
153-
-- then you probably don't want to write the last example with @COALESCE@,
154-
-- which would result in a table scan. There are further caveats if
155-
-- @id@ can be null or you want null treated sensibly as a component
156-
-- of @IN@ or @NOT IN@.
149+
-- > (Only (In [] :: In [Int]))
150+
--
151+
-- Note that at as of PostgreSQL 9.4, the query planner cannot see inside
152+
-- the @COALESCE@ operator, so if you have an index on @id@ then you
153+
-- probably don't want to write the last example with @COALESCE@, which
154+
-- would result in a table scan. There are further caveats if @id@ can
155+
-- be null or you want null treated sensibly as a component of @IN@ or
156+
-- @NOT IN@.
157157

158158
newtype In a = In a
159159
deriving (Eq, Ord, Read, Show, Typeable, Functor)
@@ -218,7 +218,7 @@ newtype Savepoint = Savepoint Query
218218
deriving (Eq, Ord, Show, Read, Typeable)
219219

220220
-- | Represents a @VALUES@ table literal, usable as an alternative
221-
-- to @executeMany@ and @returning@. The main advantage is that
221+
-- to 'executeMany' and 'returning'. The main advantage is that
222222
-- you can parametrize more than just a single @VALUES@ expression.
223223
-- For example, here's a query to insert a thing into one table
224224
-- and some attributes of that thing into another, returning the
@@ -231,7 +231,7 @@ newtype Savepoint = Savepoint Query
231231
-- > ), new_attributes AS (
232232
-- > INSERT INTO thing_attributes
233233
-- > SELECT new_thing.id, attrs.*
234-
-- > FROM new_thing JOIN ? attrs
234+
-- > FROM new_thing JOIN ? attrs ON TRUE
235235
-- > ) SELECT * FROM new_thing
236236
-- > |] ("foo", Values [ "int4", "text" ]
237237
-- > [ ( 1 , "hello" )
@@ -257,7 +257,8 @@ newtype Savepoint = Savepoint Query
257257
-- is turned into a properly quoted identifier, the type name is case
258258
-- sensitive and must be as it appears in the @pg_type@ table. Thus,
259259
-- you must write @timestamptz@ instead of @timestamp with time zone@,
260-
-- @int4@ instead of @integer@, @_int8@ instead of @bigint[]@, etcetera.
260+
-- @int4@ instead of @integer@ or @serial@, @_int8@ instead of @bigint[]@,
261+
-- etcetera.
261262
--
262263
-- You may omit the type names, however, if you do so the list
263264
-- of values must be non-empty, and postgresql must be able to infer

0 commit comments

Comments
 (0)