mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(Postgres Node): Empty return data fix for Postgres and MySQL (#7016)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -305,7 +305,7 @@ describe('Test MySql V2, operations', () => {
|
||||
|
||||
const runQueries: QueryRunner = configureQueryRunner.call(
|
||||
fakeExecuteFunction,
|
||||
nodeOptions,
|
||||
{ ...nodeOptions, nodeVersion: 2 },
|
||||
pool,
|
||||
);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user