on dev help sign in
docs
commit0fcdcd0c6a293d10ac7e89049bcefdede313356e authorEitan Chatav <eitan.chatav@gmail.com> dateFri 22 Jun 2018, 19:32 (8 years ago) parent2eb541d
6 files changed+15−15
squeal-postgresql/src/Squeal/PostgreSQL.hs+1−1 squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+1−1 squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+6−5 squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+4−4 squeal-postgresql/src/Squeal/PostgreSQL/Render.hs+2 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+1−4
squeal-postgresql/src/Squeal/PostgreSQL.hs+1−1
@@ -83,7 +83,7 @@ let
8383 OnDeleteCascade OnUpdateCascade `As` #fk_user_id :* Nil )
8484:}
8585
86−We can easily see the generated SQL is unsuprising looking.
86+We can easily see the generated SQL is unsurprising looking.
8787
8888>>> printSQL setup
8989CREATE TABLE "users" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_users" PRIMARY KEY ("id"));
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+1−1
@@ -314,7 +314,7 @@ instance ToParam x ty => ToAliasedParam x (alias ::: ty) where
314314 Just x -> K . Just . unK $ toParam @x @ty x
315315
316316-- | A `ToColumnParam` constraint lifts the `ToParam` encoding
317−-- of a `Type` to a `ColumnType`, encoding `Maybe`s to `Null`s. You should
317+-- of a `Type` to a `NullityType`, encoding `Maybe`s to `Null`s. You should
318318-- not define instances of `ToColumnParam`, just use the provided instances.
319319class ToColumnParam (x :: Type) (ty :: NullityType) where
320320 -- | >>> toColumnParam @Int16 @('NotNull 'PGint2) 0
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+6−5
@@ -151,7 +151,8 @@ createTable tab columns constraints = UnsafeDefinition $
151151
152152{-| `createTableIfNotExists` creates a table if it doesn't exist, but does not add it to the schema.
153153Instead, the schema already has the table so if the table did not yet exist, the schema was wrong.
154−`createTableIfNotExists` fixes this. Interestingly, this property makes it an idempotent in the `Category` `Definition`.
154+`createTableIfNotExists` fixes this. Interestingly, this property makes it an idempotent in
155+the `Category` of `Definition`s.
155156
156157>>> :set -XOverloadedLabels -XTypeApplications
157158>>> type Table = '[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGfloat4]
@@ -789,7 +790,7 @@ alterType ty = UnsafeAlterColumn $ "TYPE" <+> renderColumnTypeExpression ty
789790-- CREATE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";
790791createView
791792 :: KnownSymbol view
792− => Alias view -- ^ the name of the table to add
793+ => Alias view -- ^ the name of the view to add
793794 -> Query schema '[] relation
794795 -- ^ query
795796 -> Definition schema (Create view ('View relation) schema)
@@ -932,19 +933,19 @@ default_ x ty = UnsafeColumnTypeExpression $
932933 renderColumnTypeExpression ty <+> "DEFAULT" <+> renderExpression x
933934
934935-- | not a true type, but merely a notational convenience for creating
935−-- unique identifier columns with type `'PGint2`
936+-- unique identifier columns with type `PGint2`
936937serial2, smallserial
937938 :: ColumnTypeExpression schema ('Def :=> 'NotNull 'PGint2)
938939serial2 = UnsafeColumnTypeExpression "serial2"
939940smallserial = UnsafeColumnTypeExpression "smallserial"
940941-- | not a true type, but merely a notational convenience for creating
941−-- unique identifier columns with type `'PGint4`
942+-- unique identifier columns with type `PGint4`
942943serial4, serial
943944 :: ColumnTypeExpression schema ('Def :=> 'NotNull 'PGint4)
944945serial4 = UnsafeColumnTypeExpression "serial4"
945946serial = UnsafeColumnTypeExpression "serial"
946947-- | not a true type, but merely a notational convenience for creating
947−-- unique identifier columns with type `'PGint8`
948+-- unique identifier columns with type `PGint8`
948949serial8, bigserial
949950 :: ColumnTypeExpression schema ('Def :=> 'NotNull 'PGint8)
950951serial8 = UnsafeColumnTypeExpression "serial8"
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+4−4
@@ -302,11 +302,11 @@ insertQuery_
302302insertQuery_ tab query =
303303 insertQuery tab query OnConflictDoRaise (Returning Nil)
304304
305−-- | `ColumnValue`s are values to insert or update in a row
305+-- | `ColumnValue`s are values to insert or update in a row.
306306-- `Same` updates with the same value.
307−-- `Default` inserts or updates with the @DEFAULT@ value
308−-- `Set` a value to be an `Expression`, relative to the given
309−-- row for an update, and closed for an insert.
307+-- `Default` inserts or updates with the @DEFAULT@ value.
308+-- `Set` sets a value to be an `Expression`, which can refer to
309+-- existing value in the row for an update.
310310data ColumnValue
311311 (schema :: SchemaType)
312312 (columns :: RelationType)
squeal-postgresql/src/Squeal/PostgreSQL/Render.hs+2
@@ -83,8 +83,10 @@ renderCommaSeparatedMaybe render
8383renderNat :: KnownNat n => proxy n -> ByteString
8484renderNat (_ :: proxy n) = fromString (show (natVal' (proxy# :: Proxy# n)))
8585
86+-- | A class for rendering SQL
8687class RenderSQL sql where
8788 renderSQL :: sql -> ByteString
8889
90+-- | Print SQL.
8991printSQL :: (RenderSQL sql, MonadBase IO io) => sql -> io ()
9092printSQL = liftBase . Char8.putStrLn . renderSQL
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+1−4
@@ -226,10 +226,7 @@ type (:=>) constraint ty = '(constraint,ty)
226226infixr 7 :=>
227227
228228-- | The alias operator `:::` is like a promoted version of `As`,
229−-- a type level pair between
230−-- an alias and some type, like a column alias and either a `ColumnType` or
231−-- `NullityType` or a table alias and either a `TableType` or a `RelationType`
232−-- or a constraint alias and a `TableConstraint`.
229+-- a type level pair between an alias and some type.
233230type (:::) (alias :: Symbol) ty = '(alias,ty)
234231infixr 6 :::
235232