@@ -119,7 +119,7 @@ instance RenderSQL (Definition schemas0 schemas1) where
119119instance Category Definition where
120120 id = UnsafeDefinition ";"
121121 ddl1 . ddl0 = UnsafeDefinition $
122− renderDefinition ddl0 <> "\n" <> renderDefinition ddl1
122+ renderSQL ddl0 <> "\n" <> renderSQL ddl1
123123
124124{-----------------------------------------
125125CREATE statements
@@ -225,7 +225,7 @@ renderCreation
225225 -> NP (Aliased (TableConstraintExpression sch tab schemas1)) constraints
226226 -- ^ constraints that must hold for the table
227227 -> ByteString
228−renderCreation tab columns constraints = renderQualifiedAlias tab
228+renderCreation tab columns constraints = renderSQL tab
229229 <+> parenthesized
230230 ( renderCommaSeparated renderColumnDef columns
231231 <> ( case constraints of
@@ -241,7 +241,7 @@ renderCreation tab columns constraints = renderQualifiedAlias tab
241241 :: Aliased (TableConstraintExpression sch tab schemas) constraint
242242 -> ByteString
243243 renderConstraint (constraint `As` alias) =
244− "CONSTRAINT" <+> renderSQL alias <+> renderTableConstraintExpression constraint
244+ "CONSTRAINT" <+> renderSQL alias <+> renderSQL constraint
245245
246246-- | Data types are a way to limit the kind of data that can be stored in a
247247-- table. For many applications, however, the constraint they provide is
@@ -263,6 +263,9 @@ newtype TableConstraintExpression
263263 = UnsafeTableConstraintExpression
264264 { renderTableConstraintExpression :: ByteString }
265265 deriving (GHC.Generic,Show,Eq,Ord,NFData)
266+instance RenderSQL
267+ (TableConstraintExpression sch tab schemas constraint) where
268+ renderSQL = renderTableConstraintExpression
266269
267270{-| A `check` constraint is the most generic `TableConstraint` type.
268271It allows you to specify that the value in a certain column must satisfy
@@ -298,7 +301,7 @@ check
298301 -- ^ a closed `Condition` on those subcolumns
299302 -> TableConstraintExpression sch tab schemas ('Check aliases)
300303check _cols condition = UnsafeTableConstraintExpression $
301− "CHECK" <+> parenthesized (renderExpression condition)
304+ "CHECK" <+> parenthesized (renderSQL condition)
302305
303306{-| A `unique` constraint ensure that the data contained in a column,
304307or a group of columns, is unique among all the rows in the table.
@@ -541,7 +544,7 @@ dropTable
541544 , Has tab schema ('Table table))
542545 => QualifiedAlias sch tab -- ^ table to remove
543546 -> Definition schemas (Alter sch (Drop tab schema) schemas)
544−dropTable tab = UnsafeDefinition $ "DROP TABLE" <+> renderQualifiedAlias tab <> ";"
547+dropTable tab = UnsafeDefinition $ "DROP TABLE" <+> renderSQL tab <> ";"
545548
546549{-----------------------------------------
547550ALTER statements
@@ -555,7 +558,7 @@ alterTable
555558 -> Definition schemas (Alter sch (Alter tab ('Table table1) schema) schemas)
556559alterTable tab alteration = UnsafeDefinition $
557560 "ALTER TABLE"
558− <+> renderQualifiedAlias tab
561+ <+> renderSQL tab
559562 <+> renderAlterTable alteration
560563 <> ";"
561564
@@ -605,7 +608,7 @@ addConstraint
605608 -> AlterTable sch tab schemas table1
606609addConstraint alias constraint = UnsafeAlterTable $
607610 "ADD" <+> "CONSTRAINT" <+> renderSQL alias
608− <+> renderTableConstraintExpression constraint
611+ <+> renderSQL constraint
609612
610613-- | A `dropConstraint` drops a table constraint.
611614--
@@ -843,7 +846,7 @@ createView
843846 -> Query ('[] :=> schemas) '[] view -- ^ query
844847 -> Definition schemas (Alter sch (Create vw ('View view) schema) schemas)
845848createView alias query = UnsafeDefinition $
846− "CREATE" <+> "VIEW" <+> renderQualifiedAlias alias <+> "AS"
849+ "CREATE" <+> "VIEW" <+> renderSQL alias <+> "AS"
847850 <+> renderQuery query <> ";"
848851
849852-- | Drop a view.
@@ -862,7 +865,7 @@ dropView
862865 :: (Has sch schemas schema, Has vw schema ('View view))
863866 => QualifiedAlias sch vw -- ^ view to remove
864867 -> Definition schemas (Alter sch (Drop vw schema) schemas)
865−dropView vw = UnsafeDefinition $ "DROP VIEW" <+> renderQualifiedAlias vw <> ";"
868+dropView vw = UnsafeDefinition $ "DROP VIEW" <+> renderSQL vw <> ";"
866869
867870-- | Enumerated types are created using the `createTypeEnum` command, for example
868871--
@@ -876,8 +879,8 @@ createTypeEnum
876879 -- ^ labels of the enumerated type
877880 -> Definition schemas (Alter sch (Create enum ('Typedef ('PGenum labels)) schema) schemas)
878881createTypeEnum enum labels = UnsafeDefinition $
879− "CREATE" <+> "TYPE" <+> renderQualifiedAlias enum <+> "AS" <+> "ENUM" <+>
880− parenthesized (commaSeparated (renderLabels labels)) <> ";"
882+ "CREATE" <+> "TYPE" <+> renderSQL enum <+> "AS" <+> "ENUM" <+>
883+ parenthesized (renderSQL labels) <> ";"
881884
882885-- | Enumerated types can also be generated from a Haskell type, for example
883886--
@@ -930,7 +933,7 @@ createTypeComposite
930933 -- ^ list of attribute names and data types
931934 -> Definition schemas (Alter sch (Create ty ('Typedef ('PGcomposite fields)) schema) schemas)
932935createTypeComposite ty fields = UnsafeDefinition $
933− "CREATE" <+> "TYPE" <+> renderQualifiedAlias ty <+> "AS" <+> parenthesized
936+ "CREATE" <+> "TYPE" <+> renderSQL ty <+> "AS" <+> parenthesized
934937 (renderCommaSeparated renderField fields) <> ";"
935938 where
936939 renderField :: Aliased (TypeExpression schemas) x -> ByteString
@@ -981,7 +984,7 @@ dropType
981984 => QualifiedAlias sch td
982985 -- ^ name of the user defined type
983986 -> Definition schemas (Alter sch (Drop td schema) schemas)
984−dropType tydef = UnsafeDefinition $ "DROP" <+> "TYPE" <+> renderQualifiedAlias tydef <> ";"
987+dropType tydef = UnsafeDefinition $ "DROP" <+> "TYPE" <+> renderSQL tydef <> ";"
985988
986989-- | `ColumnTypeExpression`s are used in `createTable` commands.
987990newtype ColumnTypeExpression (schemas :: SchemasType) (ty :: ColumnType)