on dev help sign in
use renderNat and renderSymbol
commit5b34e498a09771fa91135c1e3dbd7863219f61ce authorEitan Chatav <eitan.chatav@gmail.com> dateMon 14 Aug 2017, 11:53 (9 years ago) parentbed538d
1 file changed+7−11
squeel-postgresql/src/Squeel/PostgreSQL/Statement.hs+7−11
squeel-postgresql/src/Squeel/PostgreSQL/Statement.hs+7−11
@@ -53,9 +53,8 @@ class (PGTyped (BaseType ty), KnownNat n)
5353 => HasParameter (n :: Nat) params ty | n params -> ty where
5454 param :: proxy n -> Expression params tables grouping ty
5555 param _ = UnsafeExpression $ parenthesized $
56− "$" <> paramNum <+> "::" <+> renderTypeExpression (pgtype @(BaseType ty))
57− where
58− paramNum = fromString $ show $ natVal (Proxy @n)
56+ "$" <> renderNat (Proxy @n) <+> " :: "
57+ <+> renderTypeExpression (pgtype @(BaseType ty))
5958instance {-# OVERLAPPING #-} PGTyped (BaseType ty1)
6059 => HasParameter 1 (ty1:tys) ty1
6160instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
@@ -409,7 +408,7 @@ class (KnownSymbol table, KnownSymbol column)
409408 :: (tables ~ '[table ::: columns], HasColumn column columns ty)
410409 => Proxy# column
411410 -> Expression params tables ('Grouped bys) ty
412− getGroup1 column = UnsafeExpression $ fromString (symbolVal' column)
411+ getGroup1 column = UnsafeExpression $ renderSymbol column
413412 getGroup2
414413 :: (HasTable table tables columns, HasColumn column columns ty)
415414 => Alias table
@@ -465,7 +464,7 @@ newtype Table
465464class KnownSymbol table => HasTable table tables columns
466465 | table tables -> columns where
467466 getTable :: Proxy# table -> Table tables columns
468− getTable table = UnsafeTable $ fromString $ symbolVal' table
467+ getTable table = UnsafeTable $ renderSymbol table
469468instance {-# OVERLAPPING #-} KnownSymbol table
470469 => HasTable table ((table ::: columns) ': tables) columns
471470instance {-# OVERLAPPABLE #-}
@@ -671,20 +670,17 @@ char
671670 :: KnownNat n
672671 => proxy n
673672 -> TypeExpression ('Required ('Null ('PGchar n)))
674−char (_ :: proxy n) = UnsafeTypeExpression $
675− "char(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
673+char p = UnsafeTypeExpression $ "char(" <> renderNat p <> ")"
676674character
677675 :: KnownNat n
678676 => proxy n
679677 -> TypeExpression ('Required ('Null ('PGchar n)))
680−character (_ :: proxy n) = UnsafeTypeExpression $
681− "character(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
678+character p = UnsafeTypeExpression $ "character(" <> renderNat p <> ")"
682679varchar
683680 :: KnownNat n
684681 => proxy n
685682 -> TypeExpression ('Required ('Null ('PGvarchar n)))
686−varchar (_ :: proxy n) = UnsafeTypeExpression $
687− "varchar(" <> fromString (show (natVal' (proxy# :: Proxy# n))) <> ")"
683+varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
688684characterVarying
689685 :: KnownNat n
690686 => proxy n