Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

addColumns throws an error with AlwaysDense address mapping with empty values #1027

Open
jho14 opened this issue Jul 8, 2022 · 1 comment
Assignees
Labels
Bug Something isn't working Impact: Medium

Comments

@jho14
Copy link

jho14 commented Jul 8, 2022

Calling addColumns does not work with the address mapping option AlwaysDense but works with AlwaysSparse. An error is only thrown when using buildEmpty as opposed to using buildFromArray. The test also appears to fail even when inserting columns into an index other than 0 so long as there are empty cell values in the index of the column that is being inserted.

Build Empty

Test with "AlwaysDense" throws an error
Test with "AlwaysSparse" succeeds

const engine = HyperFormula.buildEmpty({ chooseAddressMappingPolicy: new AlwaysDense() });
engine.addSheet();
engine.setCellContents({ col: 0, row: 0, sheet: 0 }, 1);
engine.setCellContents({ col: 0, row: 1, sheet: 0 }, 2);
engine.setCellContents({ col: 0, row: 5, sheet: 0 }, 5);
engine.addColumns(0, [0, 1]);

Error:

TypeError: Cannot read properties of undefined (reading 'splice')
 ❯ DenseStrategy.addColumns node_modules/hyperformula/commonjs/DependencyGraph/AddressMapping/DenseStrategy.js:153:45
 ❯ AddressMapping.addColumns node_modules/hyperformula/commonjs/DependencyGraph/AddressMapping/AddressMapping.js:278:20
 ❯ node_modules/hyperformula/commonjs/DependencyGraph/DependencyGraph.js:809:31
 ❯ EmptyStatistics.measure node_modules/hyperformula/commonjs/statistics/Statistics.js:114:20
 ❯ DependencyGraph.addColumns node_modules/hyperformula/commonjs/DependencyGraph/DependencyGraph.js:808:18
 ❯ Operations.doAddColumns node_modules/hyperformula/commonjs/Operations.js:1152:57
 ❯ Operations.addColumns node_modules/hyperformula/commonjs/Operations.js:315:16
 ❯ CrudOperations.addColumns node_modules/hyperformula/commonjs/CrudOperations.js:139:23
 ❯ HyperFormula.addColumns node_modules/hyperformula/commonjs/HyperFormula.js:1577:66
  • HyperFormula version: 2.0.0
  • Operating System: MacOS M1

When using build from array both address mapping options succeed

const engine = HyperFormula.buildFromArray([[1], [2], [], [], [], [5]], {
    chooseAddressMappingPolicy: new AlwaysDense(),
});
engine.addColumns(0, [0, 1]);
@jho14 jho14 added the Bug Something isn't working label Jul 8, 2022
@sequba
Copy link
Contributor

sequba commented Jul 11, 2022

Hi @jho14, I am sorry you experienced an issue with HyperFormula. I can confirm it is a bug. Our team will fix it in one of the upcoming releases. Thank you for reporting the issue.

Might be related to #855

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug Something isn't working Impact: Medium
Projects
None yet
Development

No branches or pull requests

2 participants