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

Searching into json nested attributes does not works #276

Open
ThibaultRuby opened this issue Aug 16, 2023 · 0 comments
Open

Searching into json nested attributes does not works #276

ThibaultRuby opened this issue Aug 16, 2023 · 0 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ThibaultRuby
Copy link
Collaborator

ThibaultRuby commented Aug 16, 2023

Affected version : v2.0.1

Current behavior:
When trying to use filter on nested attributes:

  const myModel = new MyModel(); // With any Dynamodels model
  const value = await myModel
    .query()
    .keys({
      pk: 'something',
    })
    .filter(attr('key.#key2').eq('something-to-match'))
    .execAll();

We get the following error:

ValidationException: ExpressionAttributeNames contains invalid key: Syntax error; key: "#key1.#key2f1a48369fb1b4fbf98c2ec8893a95063"

When it should just returns the filtered list.

The issues seems to be related to ExpressionAttributeNames mapping that is like this :

ExpressionAttributeNames: {
    '#sk': 'sk',
    '#key1.#key2f1a48369fb1b4fbf98c2ec8893a95063': 'key1.#key2'
  }

When it should be like that:

ExpressionAttributeNames: {
    '#sk': 'sk',
    '#key12f1a48369fb1b4fbf98c2ec8893a95063' : 'key1',
    '#key2<some-other-uuid>: 'key2'
  }

Imho, we should just be able to type 'key1.key2.key3' and Dynamodels should parse this and understand that this is a nested attribute case and correctly fills the ExpressionAttributeNames.

@ThibaultRuby ThibaultRuby added the bug Something isn't working label Aug 16, 2023
@ThibaultRuby ThibaultRuby self-assigned this Aug 16, 2023
@MarioArnt MarioArnt added the good first issue Good for newcomers label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants