Skip to content

listNamedExpressions will not return the expected result #638

Closed

Description

@wojciechczerniak

Description

listNamedExpressions can return a flat array with strings that are names of the expressions. But expressions can be scoped and the same name can be used. Shouldn't listNamedExpressions have a scope argument to list all available expression in the context? Then listNamedExpressions(undefined) will return global scope or all named expressions in some other way?

Steps to reproduce

  1. Add myName expression with scope Sheet 1
  2. Add myName expression with scope Sheet 2
  3. Add myName expression with global scope
  4. What will listNamedExpressions return? We have a conflict for a simple array list of strings

Demo

  it('listing named expressions', () => {
    const engine = HyperFormula.buildFromSheets({ 'Sheet 1': [[]], 'Sheet 2': [[]] })
    engine.addNamedExpression('myName', '=42', 'Sheet 1')
    engine.addNamedExpression('myName', '=42', 'Sheet 2')
    engine.addNamedExpression('myName', '=42')

    const namedExpressions = engine.listNamedExpressions()

    expect(namedExpressions).toEqual([
      'myName',
      'myName',  // ????
    ])
  })

Your environment

  • HyperFormula version: 0.5.0
  • Browser Name and version: any
  • Operating System: any

Activity

  1. added
    Bug
    on Apr 15, 2021
  2. self-assigned this
    on Apr 15, 2021
  3. izulin commented on Apr 20, 2021

    @izulin
    Contributor

    After examination, it seems that it only returns global ones.

  4. wojciechczerniak commented on Apr 20, 2021

    @wojciechczerniak
    ContributorAuthor

    Ok, so this is more a feature request. Without argument or undefined we get global scope. This is compatible with scope arguments across API and will be backward compatible for this method.

    What we're missing is an optional scope argument here to get named expressions for a scope?

  5. added
    API
    on Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

APIBug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions