diff --git a/src/utils/sharedUtils.js b/src/utils/sharedUtils.js index 54d1496..b79a742 100644 --- a/src/utils/sharedUtils.js +++ b/src/utils/sharedUtils.js @@ -11,9 +11,9 @@ const VARIABLE_REGEX = /^[a-zA-Z_]\w*$/; // vars of form aA4_f allowed export function getColumNameForJsonField(jsonField) { // ignoring sonar security error as md5 function is not used for security // Md5 function is used here to increase the length of jsonfield to more than 64 characters - return crypto.createHash('md5').update(jsonField).digest('hex'); //NOSONAR + const hash = crypto.createHash('md5').update(jsonField).digest('hex'); //NOSONAR + return "col_" + hash; } - export function isAlphaNumChar(char) { char = char.charCodeAt(0); if (!(char > 47 && char < 58) && // numeric (0-9) @@ -69,4 +69,4 @@ export function isNestedVariableNameLike(nameToTest) { } } return true; -} \ No newline at end of file +} diff --git a/test/unit/utils/db-test.spec.js b/test/unit/utils/db-test.spec.js index af0e6ba..76c6ae3 100644 --- a/test/unit/utils/db-test.spec.js +++ b/test/unit/utils/db-test.spec.js @@ -928,7 +928,7 @@ describe('Unit tests for db.js', function () { const tableName = 'test.hello'; await deleteDocuments(tableName, "$.x<10 AND $.hotel.name='oyo'", ['hotel.name']); expect(savedSql).to.eql("DELETE FROM test.hello WHERE document->>\"$.x\"<10" + - " AND b978c733175ca5d9503b1cc095eece1f='oyo';"); + " AND col_b978c733175ca5d9503b1cc095eece1f='oyo';"); mockedFunctions.connection.execute = saveExecute; }); }); @@ -2566,7 +2566,7 @@ describe('Unit tests for db.js', function () { await _validateQueryPass("$.s<10 && !$.j.k || $.y!='hello'", ["s", "j.k"], "SELECT documentID,document FROM test.customer " + - "WHERE 03c7c0ace395d80182db07ae2c30f034<10 && !91e12519d4a93e0ce72a98c42383e747 " + + "WHERE col_03c7c0ace395d80182db07ae2c30f034<10 && !col_91e12519d4a93e0ce72a98c42383e747 " + "|| document->>\"$.y\"!='hello' LIMIT 1000"); }); diff --git a/test/unit/utils/query-test.spec.js b/test/unit/utils/query-test.spec.js index 937ca53..e82dff2 100644 --- a/test/unit/utils/query-test.spec.js +++ b/test/unit/utils/query-test.spec.js @@ -269,7 +269,8 @@ describe('Query Utils test', function () { it('should transformCocoToSQLQuery success cases with index field', function () { expect(Query.transformCocoToSQLQuery("$.y>5 || $.x > 10 && $.price.tax = 18", ["x", "price.tax"])) - .to.eql('document->>"$.y">5 || 9dd4e461268c8034f5c8564e155c67a6 > 10 && 6a1a731895e201b727851bc567ac1e8a = 18'); + // eslint-disable-next-line max-len + .to.eql('document->>"$.y">5 || col_9dd4e461268c8034f5c8564e155c67a6 > 10 && col_6a1a731895e201b727851bc567ac1e8a = 18'); }); it('should transformCocoToSQLQuery error cases', function () {