@@ -383,12 +383,18 @@ data By
383383 (tables :: [(Symbol,[(Symbol,ColumnType)])])
384384 (tabcol :: (Symbol,Symbol)) where
385385 By
386+ :: (tables ~ '[table ::: columns], HasColumn column columns ty)
387+ => Alias column
388+ -> By tables '(table, column)
389+ By2
386390 :: (HasTable table tables columns, HasColumn column columns ty)
387391 => (Alias table, Alias column)
388392 -> By tables '(table, column)
389393
390394renderBy :: By tables tabcolty -> ByteString
391−renderBy (By (table, column)) = renderAlias table <> "." <> renderAlias column
395+renderBy = \case
396+ By column -> renderAlias column
397+ By2 (table, column) -> renderAlias table <> "." <> renderAlias column
392398
393399data GroupByClause tables grouping where
394400 NoGroups :: GroupByClause tables 'Ungrouped
@@ -893,13 +899,17 @@ check
893899check condition = UnsafeTableConstraint $
894900 "CHECK" <+> renderExpression condition
895901
896−newtype Column
902+data Column
897903 (columns :: [(Symbol,ColumnType)])
898904 (columnty :: (Symbol,ColumnType))
899− = UnsafeColumn {renderColumn :: ByteString}
900−instance HasColumn column columns ty
901− => IsLabel column (Column columns (column ::: ty)) where
902− fromLabel symbol = UnsafeColumn (renderSymbol symbol)
905+ where
906+ Column
907+ :: HasColumn column columns ty
908+ => Alias column
909+ -> Column columns (column ::: ty)
910+
911+renderColumn :: Column columns columnty -> ByteString
912+renderColumn (Column column) = renderAlias column
903913
904914unique
905915 :: SListI subcolumns
@@ -913,7 +923,7 @@ primaryKey
913923 => NP (Column columns) subcolumns
914924 -> TableConstraint schema columns
915925primaryKey columns = UnsafeTableConstraint $
916− "PRIMARY KEY" <+> renderCommaSeparated renderColumn columns
926+ "PRIMARY KEY" <+> parenthesized (renderCommaSeparated renderColumn columns)
917927
918928type family SameTypes columns0 columns1 :: Constraint where
919929 SameTypes '[] '[] = ()