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] Raw condition does not with with query. #1618

Open
6 tasks done
bushev opened this issue Jul 14, 2023 · 0 comments
Open
6 tasks done

[BUG] Raw condition does not with with query. #1618

bushev opened this issue Jul 14, 2023 · 0 comments

Comments

@bushev
Copy link

bushev commented Jul 14, 2023

Summary:

Code sample:

const condition = new dynamoose.Condition()
  .where('userId')
  .eq(options.userId)
  .parenthesis(
    new dynamoose.Condition({
      FilterExpression: 'size (#templates) <> :size',
      ExpressionAttributeValues: {
        ':size': 0
      },
      ExpressionAttributeNames: {
        '#templates': 'templates'
      }
    })
  );

const query = myModel.query(condition);
const result = await query.all().exec();

Model

export const schema = new Schema(
  {
    userId: {
      type: String,
      hashKey: true,
      validate: new RegExp(uuidV4RegExStr, 'i'),
      required: true
    },
   createdAt: {
      type: String,
      rangeKey: true,
      required: true
    },
   templates: {
      type: Array,
      schema: [
        {
          type: Object,
          schema: {
            pId: {
              type: String,
              required: true
            },
            sec: {
              type: String,
              required: true
            }
          }
        }
      ],
      required: true
    },
  {
    timestamps: false,
  }
)

Current output and behavior (including stack trace):

TypeError: Cannot read properties of undefined (reading '0')
    at /Users/u/a/b/node_modules/dynamoose/dist/Condition.js:188:39
    at Array.reduce (<anonymous>)
    at Object.comparisonChart (/Users/u/a/b/node_modules/dynamoose/dist/Condition.js:185:108)
    at Query.ItemRetriever.getRequest (/Users/u/a/b/node_modules/dynamoose/dist/ItemRetriever.js:135:147)

Expected output and behavior:

Normal execution

Environment:

Operating System: MacOS
Operating System Version: 13.4.1 (22F82)
Node.js version (node -v): v16.13.2
NPM version: (npm -v): 8.1.2
Dynamoose version: 3.2.0

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant