InseeFr / Trevas-TS

JavaScript engine for the Validation and Transformation Language
MIT License
9 stars 8 forks source link

Count empty dataset throw error instend of 0 #137

Closed ddecrulle closed 6 days ago

ddecrulle commented 6 months ago

On my opinion, the size of an empty array [] should be 0.

I tested in storybook to do :

count(ds)

with bindings

{
  "ds": {
    "dataStructure": {
      "col_1": {
        "name": "col_1",
        "role": "MEASURE"
      }
    },
    "dataPoints": {
      "col_1": [ ]
    }
  }
}

which throw error.

laurentC35 commented 6 months ago

This line cause this issue : https://github.com/InseeFr/Trevas-JS/blob/master/packages/trevas/src/utils/datasets/operations.js#L72

r is undefined

NicoLaval commented 6 months ago

Yes, it should be 0. Bug approved