@@ -42,6 +42,14 @@ toInsertExpr vals rvName = do
4242 tuples <- mkTupleSet attrs $ toList (fmap toTuple vals)
4343 let rel = MakeStaticRelation attrs tuples
4444 pure (Insert rvName rel)
45+
46+-- | Convert a 'Tupleable' to a create a 'Define' expression which can be used to create an empty relation variable. Use 'toInsertExpr' to insert the actual tuple data. This function is typically used with 'undefined'.
47+toDefineExpr :: Tupleable a => a -> RelVarName -> DatabaseContextExpr
48+toDefineExpr val rvName = Define rvName (map NakedAttributeExpr (V.toList attrs))
49+ where
50+ attrs = toAttributes val
51+
52+
4553
4654class Tupleable a where
4755 toTuple :: a -> RelationTuple