on dev help sign in
more Nil scrapping
commit6a4524930e263c1762d0307bfc275a321f31e531 authorEitan Chatav <eitan.chatav@gmail.com> dateMon 2 Jul 2018, 15:55 (8 years ago) parent01a75e3
3 files changed+20−20
squeal-postgresql/exe/Example.hs+17−17 squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+1−1 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+2−2
squeal-postgresql/exe/Example.hs+17−17
@@ -44,18 +44,18 @@ type Schema =
4444setup :: Definition '[] Schema
4545setup =
4646 createTable #users
47− ( serial `As` #id :*
48− (text & notNullable) `As` #name :*
49− (vararray int2 & notNullable) `As` #vec :* Nil )
50− ( primaryKey #id `As` #pk_users :* Nil )
47+ ( serial `as` #id :*
48+ (text & notNullable) `as` #name :*
49+ (vararray int2 & notNullable) `as` #vec )
50+ ( primaryKey #id `as` #pk_users )
5151 >>>
5252 createTable #emails
53− ( serial `As` #id :*
54− (int & notNullable) `As` #user_id :*
55− (text & nullable) `As` #email :* Nil )
56− ( primaryKey #id `As` #pk_emails :*
53+ ( serial `as` #id :*
54+ (int & notNullable) `as` #user_id :*
55+ (text & nullable) `as` #email )
56+ ( primaryKey #id `as` #pk_emails :*
5757 foreignKey #user_id #users #id
58− OnDeleteCascade OnUpdateCascade `As` #fk_user_id :* Nil )
58+ OnDeleteCascade OnUpdateCascade `as` #fk_user_id )
5959
6060teardown :: Definition Schema '[]
6161teardown = dropTable #emails >>> dropTable #users
@@ -63,14 +63,14 @@ teardown = dropTable #emails >>> dropTable #users
6363insertUser :: Manipulation Schema '[ 'NotNull 'PGtext, 'NotNull ('PGvararray 'PGint2)]
6464 '[ "fromOnly" ::: 'NotNull 'PGint4 ]
6565insertUser = insertRows #users
66− (Default `As` #id :* Set (param @1) `As` #name :* Set (param @2) `As` #vec :* Nil) []
67− OnConflictDoNothing (Returning (#id `As` #fromOnly :* Nil))
66+ (Default `as` #id :* Set (param @1) `as` #name :* Set (param @2) `as` #vec) []
67+ OnConflictDoNothing (Returning (#id `as` #fromOnly))
6868
6969insertEmail :: Manipulation Schema '[ 'NotNull 'PGint4, 'Null 'PGtext] '[]
7070insertEmail = insertRows #emails
71− ( Default `As` #id :*
72− Set (param @1) `As` #user_id :*
73− Set (param @2) `As` #email :* Nil ) []
71+ ( Default `as` #id :*
72+ Set (param @1) `as` #user_id :*
73+ Set (param @2) `as` #email ) []
7474 OnConflictDoNothing (Returning Nil)
7575
7676getUsers :: Query Schema '[]
@@ -78,9 +78,9 @@ getUsers :: Query Schema '[]
7878 , "userEmail" ::: 'Null 'PGtext
7979 , "userVec" ::: 'NotNull ('PGvararray 'PGint2)]
8080getUsers = select
81− (#u ! #name `As` #userName :* #e ! #email `As` #userEmail :* #u ! #vec `As` #userVec :* Nil)
82− ( from (table (#users `As` #u)
83− & innerJoin (table (#emails `As` #e))
81+ (#u ! #name `as` #userName :* #e ! #email `as` #userEmail :* #u ! #vec `as` #userVec)
82+ ( from (table (#users `as` #u)
83+ & innerJoin (table (#emails `as` #e))
8484 (#u ! #id .== #e ! #user_id)) )
8585
8686data User = User { userName :: Text, userEmail :: Maybe Text, userVec :: Vector (Maybe Int16) }
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+1−1
@@ -818,7 +818,7 @@ dropView v = UnsafeDefinition $ "DROP VIEW" <+> renderAlias v <> ";"
818818
819819-- | Enumerated types are created using the `createTypeEnum` command, for example
820820--
821−-- >>> printSQL $ createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy" :* Nil)
821+-- >>> printSQL $ createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy")
822822-- CREATE TYPE "mood" AS ENUM ('sad', 'ok', 'happy');
823823createTypeEnum
824824 :: (KnownSymbol enum, SOP.All KnownSymbol labels)
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+2−2
@@ -690,8 +690,8 @@ type family With
690690class IsPGlabel (label :: Symbol) expr where label :: expr
691691instance label ~ label1
692692 => IsPGlabel label (PGlabel label1) where label = PGlabel
693−instance label ~ label1
694− => IsPGlabel label (NP PGlabel '[label1]) where label = PGlabel :* Nil
693+instance labels ~ '[label]
694+ => IsPGlabel label (NP PGlabel labels) where label = PGlabel :* Nil
695695-- | A `PGlabel` unit type with an `IsPGlabel` instance
696696data PGlabel (label :: Symbol) = PGlabel
697697-- | Renders a label