on dev help sign in
Add double quotes around aliases
commit2f36f46af0c49b2cba8643264564ab0f668ceec5 authorPetter Rasmussen <petter.rasmussen@gmail.com> dateWed 4 Apr 2018, 00:25 (9 years ago) parent24d53f6
2 files changed+9−2
squeal-postgresql/src/Squeal/PostgreSQL/Render.hs+5 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+4−2
squeal-postgresql/src/Squeal/PostgreSQL/Render.hs+5
@@ -22,6 +22,7 @@ module Squeal.PostgreSQL.Render
2222 parenthesized
2323 , (<+>)
2424 , commaSeparated
25+ , doubleQuoted
2526 , renderCommaSeparated
2627 , renderCommaSeparatedMaybe
2728 , renderNat
@@ -48,6 +49,10 @@ str1 <+> str2 = str1 <> " " <> str2
4849commaSeparated :: [ByteString] -> ByteString
4950commaSeparated = ByteString.intercalate ", "
5051
52+-- | Add double quotes around a `ByteString`.
53+doubleQuoted :: ByteString -> ByteString
54+doubleQuoted str = "\"" <> str <> "\""
55+
5156-- | Comma separate the renderings of a heterogeneous list.
5257renderCommaSeparated
5358 :: SListI xs
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+4−2
@@ -110,6 +110,8 @@ import GHC.TypeLits
110110
111111import qualified Generics.SOP.Type.Metadata as Type
112112
113+import Squeal.PostgreSQL.Render
114+
113115-- | `PGType` is the promoted datakind of PostgreSQL types.
114116--
115117-- >>> import Squeal.PostgreSQL.Schema
@@ -358,9 +360,9 @@ instance alias1 ~ alias2 => IsLabel alias1 (Alias alias2) where
358360 fromLabel = Alias
359361
360362-- | >>> renderAlias #jimbob
361−-- "jimbob"
363+-- "\"jimbob\""
362364renderAlias :: KnownSymbol alias => Alias alias -> ByteString
363−renderAlias = fromString . symbolVal
365+renderAlias = doubleQuoted . fromString . symbolVal
364366
365367-- | The `As` operator is used to name an expression. `As` is like a demoted
366368-- version of `:::`.