fix(Postgres Node): Empty return data fix for Postgres and MySQL (#7016)

This commit is contained in:
Michael Kret
2023-08-25 18:38:09 +03:00
committed by GitHub
parent f02f6b659a
commit 176ccd62bc
9 changed files with 86 additions and 22 deletions

View File

@@ -11,7 +11,7 @@ export class MySql extends VersionedNodeType {
name: 'mySql',
icon: 'file:mysql.svg',
group: ['input'],
defaultVersion: 2.1,
defaultVersion: 2.2,
description: 'Get, add and update data in MySQL',
};
@@ -19,6 +19,7 @@ export class MySql extends VersionedNodeType {
1: new MySqlV1(baseDescription),
2: new MySqlV2(baseDescription),
2.1: new MySqlV2(baseDescription),
2.2: new MySqlV2(baseDescription),
};
super(nodeVersions, baseDescription);

View File

@@ -305,7 +305,7 @@ describe('Test MySql V2, operations', () => {
const runQueries: QueryRunner = configureQueryRunner.call(
fakeExecuteFunction,
nodeOptions,
{ ...nodeOptions, nodeVersion: 2 },
pool,
);

View File

@@ -45,7 +45,7 @@ describe('Test MySql V2, runQueries', () => {
});
it('should execute in "Single" mode, should return success true', async () => {
const nodeOptions: IDataObject = { queryBatching: BATCH_MODE.SINGLE };
const nodeOptions: IDataObject = { queryBatching: BATCH_MODE.SINGLE, nodeVersion: 2 };
const pool = createFakePool(fakeConnection);
const fakeExecuteFunction = createMockExecuteFunction({}, mySqlMockNode);
@@ -81,7 +81,7 @@ describe('Test MySql V2, runQueries', () => {
});
it('should execute in "independently" mode, should return success true', async () => {
const nodeOptions: IDataObject = { queryBatching: BATCH_MODE.INDEPENDENTLY };
const nodeOptions: IDataObject = { queryBatching: BATCH_MODE.INDEPENDENTLY, nodeVersion: 2 };
const pool = createFakePool(fakeConnection);
@@ -126,7 +126,7 @@ describe('Test MySql V2, runQueries', () => {
});
it('should execute in "transaction" mode, should return success true', async () => {
const nodeOptions: IDataObject = { queryBatching: BATCH_MODE.TRANSACTION };
const nodeOptions: IDataObject = { queryBatching: BATCH_MODE.TRANSACTION, nodeVersion: 2 };
const pool = createFakePool(fakeConnection);

View File

@@ -8,7 +8,7 @@ export const versionDescription: INodeTypeDescription = {
name: 'mySql',
icon: 'file:mysql.svg',
group: ['input'],
version: [2, 2.1],
version: [2, 2.1, 2.2],
subtitle: '={{ $parameter["operation"] }}',
description: 'Get, add and update data in MySQL',
defaults: {

View File

@@ -167,7 +167,23 @@ export function prepareOutput(
}
if (!returnData.length) {
returnData.push({ json: { success: true } });
if ((options?.nodeVersion as number) < 2.2) {
returnData.push({ json: { success: true } });
} else {
const isSelectQuery = statements
.filter((statement) => !statement.startsWith('--'))
.every((statement) =>
statement
.replace(/\/\*.*?\*\//g, '') // remove multiline comments
.replace(/\n/g, '')
.toLowerCase()
.startsWith('select'),
);
if (!isSelectQuery) {
returnData.push({ json: { success: true } });
}
}
}
return returnData;