Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes csv export of saved searches that have _source field #43123

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ describe('formatCsvValues', function () {
const separator = ',';
const fields = ['foo', 'bar'];
const mockEscapeValue = val => val;

describe('with _source as one of the fields', function () {
const formatsMap = new Map();
const formatCsvValues = createFormatCsvValues(mockEscapeValue, separator, ['foo', '_source'], formatsMap);
it('should return full _source for _source field', function () {
const values = {
foo: 'baz',
};
expect(formatCsvValues(values)).to.be('baz,{"foo":"baz"}');
});
});
describe('without field formats', function () {
const formatsMap = new Map();
const formatCsvValues = createFormatCsvValues(mockEscapeValue, separator, fields, formatsMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export function createFormatCsvValues(escapeValue, separator, fields, formatsMap
return function formatCsvValues(values) {
return fields
.map(field => {
const value = values[field];
let value;
if (field === '_source') {
value = values;
} else {
value = values[field];
}
if (isNull(value) || isUndefined(value)) {
return '';
}
Expand Down