Fix JMESPath query not working anymore for arrays with numbers

This commit is contained in:
jos 2019-03-31 20:03:56 +02:00
parent 801921867d
commit ebe7bafe51
1 changed files with 4 additions and 2 deletions

View File

@ -63,7 +63,7 @@ function showTransformModal (node, container) {
' </div>' + ' </div>' +
' </td>' + ' </td>' +
' </tr>' + ' </tr>' +
' <tr>' + ' <tr id="selectFieldsPart">' +
' <th>' + translate('transformWizardSelectFields') + '</th>' + ' <th>' + translate('transformWizardSelectFields') + '</th>' +
' <td class="jsoneditor-jmespath-filter">' + ' <td class="jsoneditor-jmespath-filter">' +
' <select class="jsoneditor-jmespath-select-fields" id="selectFields" multiple></select>' + ' <select class="jsoneditor-jmespath-select-fields" id="selectFields" multiple></select>' +
@ -184,7 +184,9 @@ function showTransformModal (node, container) {
function generateQueryFromWizard () { function generateQueryFromWizard () {
if (filterField.value && filterRelation.value && filterValue.value) { if (filterField.value && filterRelation.value && filterValue.value) {
var field1 = filterField.value; var field1 = filterField.value;
var examplePath = ['0'].concat(util.parsePath('.' + field1)) var examplePath = field1 !== '@'
? ['0'].concat(util.parsePath('.' + field1))
: ['0']
var exampleValue = util.get(value, examplePath) var exampleValue = util.get(value, examplePath)
// TODO: move _stringCast into a static util function // TODO: move _stringCast into a static util function
var value1 = typeof exampleValue === 'string' var value1 = typeof exampleValue === 'string'