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

[BUG] batchGet returns an empty array if the string manipulation is done using get in model #1442

Open
6 tasks done
dharmin opened this issue Jul 25, 2022 · 0 comments · May be fixed by #1607
Open
6 tasks done

[BUG] batchGet returns an empty array if the string manipulation is done using get in model #1442

dharmin opened this issue Jul 25, 2022 · 0 comments · May be fixed by #1607

Comments

@dharmin
Copy link

dharmin commented Jul 25, 2022

Summary:

batchGet returns an empty array if the string manipulation is done using get in range key.

It only happens if the string gets changed.

Code sample:

    const UserWithoutStringManipulation = dynamoose.model("User", { "id": Number, "name": { "type": String, "rangeKey": true, get: (value: string) => value } });
    const UserWithStringManipulation = dynamoose.model("User", { "id": Number, "name": { "type": String, "rangeKey": true, get: (value: string) => value.toUpperCase() } });

    console.log('batchGet without string manipulation');
    try {
      const myUsers = await UserWithoutStringManipulation.batchGet([{ "id": 1, "name": "Tim" }]);
      console.log(myUsers);
    } catch (error) {
      console.error(error);
    }

    console.log('batchGet with string manipulation');
    try {
      const myUsers = await UserWithStringManipulation.batchGet([{ "id": 1, "name": "Tim" }]);
      console.log(myUsers);
    } catch (error) {
      console.error(error);
    }

    console.log('get using string manipulation');
    try {
      const myUsers = await UserWithStringManipulation.get({ "id": 1, "name": "Tim" });
      console.log(myUsers);
    } catch (error) {
      console.error(error);
    }

Current output and behavior (including stack trace):

batchGet without string manipulation
[
  Document { name: 'Tim', id: 1 },
  unprocessedKeys: [],
  populate: [Function: PopulateDocuments],
  toJSON: [Function: documentToJSON]
]
batchGet with string manipulation
[
  unprocessedKeys: [],
  populate: [Function: PopulateDocuments],
  toJSON: [Function: documentToJSON]
]
get using string manipulation
Document { name: 'TIM', id: 1 }

Expected output and behavior:

batchGet without string manipulation
[
  Document { name: 'Tim', id: 1 },
  unprocessedKeys: [],
  populate: [Function: PopulateDocuments],
  toJSON: [Function: documentToJSON]
]
batchGet with string manipulation
[
  Document { name: 'Tim', id: 1 },
  unprocessedKeys: [],
  populate: [Function: PopulateDocuments],
  toJSON: [Function: documentToJSON]
]
get using string manipulation
Document { name: 'TIM', id: 1 }

Environment:

Operating System:
Operating System Version: Arch Linux x86_64
Node.js version (node -v): v16.15.1
Yarn version: (yarn -v): 1.22.15
Dynamoose version: 2.8.6

Other:

  • I have read through the Dynamoose documentation before posting this issue
  • I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
  • I have searched the internet and Stack Overflow to ensure this issue hasn't been raised or answered before
  • I have tested the code provided and am confident it doesn't work as intended
  • I have filled out all fields above
  • I am running the latest version of Dynamoose
@dharmin dharmin changed the title [BUG] batchGet [BUG] batchGet returns an empty array if the string manipulation is done using get in range key Jul 25, 2022
@dharmin dharmin changed the title [BUG] batchGet returns an empty array if the string manipulation is done using get in range key [BUG] batchGet returns an empty array if the string manipulation is done using get in model Jul 25, 2022
@gbasto gbasto linked a pull request May 30, 2023 that will close this issue
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant