mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(MySQL Node): Only escape table names when needed (#8246)
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
addWhereClauses,
|
||||
addSortRules,
|
||||
replaceEmptyStringsByNulls,
|
||||
escapeSqlIdentifier,
|
||||
} from '../../v2/helpers/utils';
|
||||
|
||||
const mySqlMockNode: INode = {
|
||||
@@ -148,3 +149,29 @@ describe('Test MySql V2, replaceEmptyStringsByNulls', () => {
|
||||
expect(replacedData).toEqual([{ json: { id: 1, name: '' } }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test MySql V2, escapeSqlIdentifier', () => {
|
||||
it('should escape fully qualified identifier', () => {
|
||||
const input = 'db_name.tbl_name.col_name';
|
||||
const escapedIdentifier = escapeSqlIdentifier(input);
|
||||
expect(escapedIdentifier).toEqual('`db_name`.`tbl_name`.`col_name`');
|
||||
});
|
||||
|
||||
it('should escape table name only', () => {
|
||||
const input = 'tbl_name';
|
||||
const escapedIdentifier = escapeSqlIdentifier(input);
|
||||
expect(escapedIdentifier).toEqual('`tbl_name`');
|
||||
});
|
||||
|
||||
it('should escape fully qualified identifier with backticks', () => {
|
||||
const input = '`db_name`.`tbl_name`.`col_name`';
|
||||
const escapedIdentifier = escapeSqlIdentifier(input);
|
||||
expect(escapedIdentifier).toEqual('`db_name`.`tbl_name`.`col_name`');
|
||||
});
|
||||
|
||||
it('should escape identifier with dots', () => {
|
||||
const input = '`db_name`.`some.dotted.tbl_name`';
|
||||
const escapedIdentifier = escapeSqlIdentifier(input);
|
||||
expect(escapedIdentifier).toEqual('`db_name`.`some.dotted.tbl_name`');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user