Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cryptic SyntaxError when passing only one argument to lookup #379

Closed
mz8i opened this issue Nov 6, 2024 · 2 comments · Fixed by #380
Closed

Cryptic SyntaxError when passing only one argument to lookup #379

mz8i opened this issue Nov 6, 2024 · 2 comments · Fixed by #380
Assignees
Labels
enhancement New feature or request

Comments

@mz8i
Copy link
Contributor

mz8i commented Nov 6, 2024

Running the following code:

const a = aq.from([
    {A: 'a1', B: 'b1'},
    {A: 'a2', B: 'b2'}
])

const b = aq.from([
    {B: 'b1', C: 'c1'},
    {B: 'b2', C: 'c2'}
])

const c = a.lookup(b);

most intuitively, I would have expected this to infer the natural default for the values argument (which would be all columns apart from the one that is specified/inferred as the on argument) and yield a result equivalent to:

aq.from([
    {A: 'a1', B: 'b1', C: 'c1'},
    {A: 'a2', B: 'b2', C: 'c2'}
])

Instead, a SyntaxError is raised, presumably because the library internals generate invalid syntax due to an empty list of expressions passed in.

Please consider:

  • allowing using lookup with only one argument, or
  • improving the docs to specify that at least one expression is required (especially as the ...values rest argument comes after on which in the TypeScript typings is marked as optional, so it's easy to assume that everything apart from other is optional)
@jheer jheer added the enhancement New feature or request label Nov 6, 2024
@jheer jheer self-assigned this Nov 6, 2024
@jheer
Copy link
Member

jheer commented Nov 6, 2024

Thanks for the issue! I've added changes to make lookup keys and values optional in #380.

@mz8i
Copy link
Contributor Author

mz8i commented Nov 6, 2024

Amazing, thank you!

@jheer jheer closed this as completed in #380 Nov 6, 2024
@jheer jheer mentioned this issue Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants