mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
⚡ Fix issue with dot-notation on redis node
This commit is contained in:
parent
384db05483
commit
adff086ea2
|
@ -158,6 +158,33 @@ export class Redis implements INodeType {
|
||||||
description: 'The type of the key to get.',
|
description: 'The type of the key to get.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
displayName: 'Options',
|
||||||
|
name: 'options',
|
||||||
|
type: 'collection',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'get'
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
placeholder: 'Add Option',
|
||||||
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Dot Notation',
|
||||||
|
name: 'dotNotation',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description: `By default does dot-notation get used in property names.<br />
|
||||||
|
This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.<br />
|
||||||
|
If that is not intended this can be deactivated, it will then set { "a.b": value } instead.
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// keys
|
// keys
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -292,7 +319,7 @@ export class Redis implements INodeType {
|
||||||
|
|
||||||
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
// Parses the given value in a number if it is one else returns a string
|
// Parses the given value in a number if it is one else returns a string
|
||||||
function getParsedValue (value: string): string | number {
|
function getParsedValue(value: string): string | number {
|
||||||
if (value.match(/^[\d\.]+$/) === null) {
|
if (value.match(/^[\d\.]+$/) === null) {
|
||||||
// Is a string
|
// Is a string
|
||||||
return value;
|
return value;
|
||||||
|
@ -306,7 +333,7 @@ export class Redis implements INodeType {
|
||||||
function convertInfoToObject(stringData: string): IDataObject {
|
function convertInfoToObject(stringData: string): IDataObject {
|
||||||
const returnData: IDataObject = {};
|
const returnData: IDataObject = {};
|
||||||
|
|
||||||
let key:string, value:string;
|
let key: string, value: string;
|
||||||
for (const line of stringData.split('\n')) {
|
for (const line of stringData.split('\n')) {
|
||||||
if (['#', ''].includes(line.charAt(0))) {
|
if (['#', ''].includes(line.charAt(0))) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -450,7 +477,15 @@ export class Redis implements INodeType {
|
||||||
const keyType = this.getNodeParameter('keyType', itemIndex) as string;
|
const keyType = this.getNodeParameter('keyType', itemIndex) as string;
|
||||||
|
|
||||||
const value = await getValue(client, keyGet, keyType) || null;
|
const value = await getValue(client, keyGet, keyType) || null;
|
||||||
set(item.json, propertyName, value);
|
|
||||||
|
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
|
||||||
|
|
||||||
|
if (options.dotNotation === false) {
|
||||||
|
item.json[propertyName] = value;
|
||||||
|
} else {
|
||||||
|
set(item.json, propertyName, value);
|
||||||
|
}
|
||||||
|
|
||||||
returnItems.push(item);
|
returnItems.push(item);
|
||||||
} else if (operation === 'keys') {
|
} else if (operation === 'keys') {
|
||||||
const keyPattern = this.getNodeParameter('keyPattern', itemIndex) as string;
|
const keyPattern = this.getNodeParameter('keyPattern', itemIndex) as string;
|
||||||
|
@ -467,7 +502,7 @@ export class Redis implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const keyName of keys) {
|
for (const keyName of keys) {
|
||||||
set(item.json, keyName, await promises[keyName]);
|
item.json[keyName] = await promises[keyName];
|
||||||
}
|
}
|
||||||
returnItems.push(item);
|
returnItems.push(item);
|
||||||
} else if (operation === 'set') {
|
} else if (operation === 'set') {
|
||||||
|
|
Loading…
Reference in a new issue