src/GuileHandler.h
branchv_0
changeset 15 051e58022783
parent 14 82bd0f57a889
child 16 2dcc22b7a424
--- a/src/GuileHandler.h	Tue Feb 05 12:41:54 2019 +0100
+++ b/src/GuileHandler.h	Tue Feb 05 20:40:32 2019 +0100
@@ -62,6 +62,14 @@
 	integer_t currentAttributeIndex = 0;
 	boolean_t includeCurrentRecord = false;
 
+	void add(vector<AttributeMetadata>& readerAttributes, vector<writer::AttributeMetadata>& writerAttributes) {
+		for (AttributeMetadata readerAttributes : readerAttributes)
+			writerAttributes.push_back({
+				readerAttributes.getAttributeName(),
+				relationalWriter->toTypeId(readerAttributes.getTypeName())
+			});
+	}
+
 	/**
 	 * @param attributeName name from relational pipe
 	 * @return variable name in Guile
@@ -206,9 +214,11 @@
 		// TODO: move to a reusable method (or use same metadata on both reader and writer side?)
 		currentWriterMetadata.clear();
 		if (currentRelationConfiguration && currentRelationConfiguration->writerMetadata.size()) {
-			currentWriterMetadata = currentRelationConfiguration->writerMetadata;
+			if (currentRelationConfiguration->inputAttributesPrepend) add(currentReaderMetadata, currentWriterMetadata);
+			currentWriterMetadata.insert(currentWriterMetadata.end(), currentRelationConfiguration->writerMetadata.begin(), currentRelationConfiguration->writerMetadata.end());
+			if (currentRelationConfiguration->inputAttributesAppend) add(currentReaderMetadata, currentWriterMetadata);
 		} else {
-			for (AttributeMetadata readerMetadata : attributes) currentWriterMetadata.push_back({readerMetadata.getAttributeName(), relationalWriter->toTypeId(readerMetadata.getTypeName())});
+			add(currentReaderMetadata, currentWriterMetadata);
 		}
 
 		if (!currentRelationConfiguration || !currentRelationConfiguration->drop) relationalWriter->startRelation(name, currentWriterMetadata, true);