Skip to content

Commit

Permalink
Fix empty formula case
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Jun 14, 2021
1 parent 517be0e commit 22f61e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/kbn-tinymath/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

const { get } = require('lodash');
const memoizeOne = require('memoize-one');
// eslint-disable-next-line import/no-unresolved
const { parse: parseFn } = require('../grammar');
const { functions: includedFunctions } = require('./functions');
Expand All @@ -23,7 +24,7 @@ function parse(input, options) {
}

try {
return parseFn(input, options);
return memoizeOne(parseFn)(input, options);
} catch (e) {
throw new Error(`Failed to parse expression. ${e.message}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ export const formulaOperation: OperationDefinition<
return [
{
type: 'function',
function: 'mathColumn',
function: currentColumn.references.length ? 'mathColumn' : 'mapColumn',
arguments: {
id: [columnId],
name: [label || defaultLabel],
expression: [currentColumn.references.length ? `"${currentColumn.references[0]}"` : ``],
expression: [currentColumn.references.length ? `"${currentColumn.references[0]}"` : ''],
},
},
];
Expand Down

0 comments on commit 22f61e9

Please sign in to comment.