mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2026-05-26 22:00:24 -04:00
fix: wrap in square brackets if needed (#1171)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { getFrequencyMaxExpression } from '../frequencyMaxUtil';
|
||||
|
||||
describe('frequencyMaxUtil - getFrequencyMaxExpression', () => {
|
||||
test('should create correct expression and wrap and escape field if needed', async () => {
|
||||
const result = getFrequencyMaxExpression('dimension with ] in it');
|
||||
|
||||
expect(result).toEqual('Max(AGGR(Count([dimension with ]] in it]), [dimension with ]] in it]))');
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,10 @@ const escapeField = (field) => {
|
||||
if (!field) {
|
||||
return field;
|
||||
}
|
||||
return `${field.replace(/\]/g, ']]')}`;
|
||||
if (/^[A-Za-z][A-Za-z0-9_]*$/.test(field)) {
|
||||
return field;
|
||||
}
|
||||
return `[${field.replace(/\]/g, ']]')}]`;
|
||||
};
|
||||
|
||||
export const needToFetchFrequencyMax = (layout) => layout?.frequencyMax === 'fetch';
|
||||
|
||||
Reference in New Issue
Block a user