lib/gooddata/models/blueprint/to_manifest.rb in gooddata-0.6.49 vs lib/gooddata/models/blueprint/to_manifest.rb in gooddata-0.6.50

- old
+ new

@@ -1,8 +1,8 @@ # encoding: UTF-8 # -# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved. +# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved. # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. module GoodData module Model @@ -123,11 +123,15 @@ def self.label_to_manifest(_project, dataset, label, mode) a = DatasetBlueprint.attribute_for_label(dataset, label) labels = DatasetBlueprint.labels_for_attribute(dataset, a) label = {}.tap do |l| - l['referenceKey'] = 1 if labels.first == label + if labels.any? { |lab| lab.key?(:reference_label) } && label[:reference_label] == true + l['referenceKey'] = 1 + elsif labels.all? { |lab| !lab.key?(:reference_label) } && labels.first == label + l['referenceKey'] = 1 + end l['populates'] = [label[:id]] l['mode'] = mode l['columnName'] = label[:column_name] || label[:id] end [label] @@ -166,10 +170,10 @@ # @param mode [String] Mode of the load. Either FULL or INCREMENTAL # @return [Hash] Manifest for a particular reference def self.reference_to_manifest(project, _dataset, reference, mode) referenced_dataset = ProjectBlueprint.find_dataset(project, reference[:dataset]) anchor = DatasetBlueprint.anchor(referenced_dataset) - label = DatasetBlueprint.labels_for_attribute(referenced_dataset, anchor).first + label = DatasetBlueprint.reference_label_for_attribtue(referenced_dataset, anchor) [{ 'populates' => [label[:id]], 'mode' => mode, 'columnName' => reference[:column_name] || reference[:dataset], 'referenceKey' => 1