on dev help sign in
make field invocation an explicit function
68a7cbeEitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+2−2
@@ -896,8 +896,8 @@ createTypeComposite ty fields = UnsafeDefinition $
896 (renderCommaSeparated renderField fields) <> ";"
896 (renderCommaSeparated renderField fields) <> ";"
897 where
897 where
898 renderField :: Aliased (TypeExpression schema) x -> ByteString
898 renderField :: Aliased (TypeExpression schema) x -> ByteString
899− renderField (typ `As` field) =
899+ renderField (typ `As` alias) =
900− renderAlias field <+> renderTypeExpression typ
900+ renderAlias alias <+> renderTypeExpression typ
901
901
902-- | Composite types can also be generated from a Haskell type, for example
902-- | Composite types can also be generated from a Haskell type, for example
903--
903--
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+9−7
@@ -46,6 +46,7 @@ module Squeal.PostgreSQL.Expression
46 -- ** Collections
46 -- ** Collections
47 , array
47 , array
48 , row
48 , row
49+ , field
49 -- ** Functions
50 -- ** Functions
50 , unsafeBinaryOp
51 , unsafeBinaryOp
51 , unsafeUnaryOp
52 , unsafeUnaryOp
@@ -354,7 +355,7 @@ null_ = UnsafeExpression "NULL"
354
355
355-- | analagous to `Just`
356-- | analagous to `Just`
356--
357--
357−-- >>> printSQL $ true
358+-- >>> printSQL $ notNull true
358-- TRUE
359-- TRUE
359notNull
360notNull
360 :: Expression schema rels grouping params ('NotNull ty)
361 :: Expression schema rels grouping params ('NotNull ty)
@@ -467,12 +468,13 @@ row
467row exprs = UnsafeExpression $ "ROW" <> parenthesized
468row exprs = UnsafeExpression $ "ROW" <> parenthesized
468 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
469 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
469
470
470−instance Has field fields ty => IsLabel field
471+field
472+ :: forall field fields ty schema from grouping params. Has field fields ty
471− ( Expression schema relation grouping params ('NotNull ('PGcomposite fields))
473+ => Expression schema from grouping params ('NotNull ('PGcomposite fields))
472− -> Expression schema relation grouping params ty ) where
474+ -> Expression schema from grouping params ty
473− fromLabel expr = UnsafeExpression $
475+field expr = UnsafeExpression $
474− parenthesized (renderExpression expr) <> "." <>
476+ parenthesized (renderExpression expr) <> "." <>
475− renderSymbol @field
477+ renderSymbol @field
476
478
477instance Semigroup
479instance Semigroup
478 (Expression schema from grouping params (nullity ('PGvararray ty))) where
480 (Expression schema from grouping params (nullity ('PGvararray ty))) where