Skip to content
This repository was archived by the owner on Jun 19, 2023. It is now read-only.
This repository was archived by the owner on Jun 19, 2023. It is now read-only.

Using ConditionExpression in Put Queries seems to be flawed, or broken #207

@bowenbrinegar

Description

@bowenbrinegar

Using the documentation of both this repository (in the Operations with Expressions section) and dynamodb-expression, I believe there is a specific issue with using conditions on put query.

(a) the documentation of this repo is missing a parenthesis (possibly un-needed UpdateExpression as well)
(b) the follow populates a putItem query successfully over and over

Model:

@table('tests')
class Test {
    @hashKey()
    id?: string;

    @rangeKey()
    name?: string;
}

Action:

import {
  FunctionExpression,
  AttributePath,
  UpdateExpression
} from '@aws/dynamodb-expressions';

import { v4 as uuidv4 } from 'uuid';

function createData() {
  const obj = Object.assign(new Test, {
    id: uuidv4(),
    name: 'same name'
  })
  const condition =  new FunctionExpression('attribute_not_exists', new AttributePath('name'));
  return mapper.put(obj, { condition: condition })
}

createData() // should work with no existing record
createData() // should throw error as name attribute already exists, but does not throw error

(c) all tests cases for FunctionExpression (at least in packages/dynamodb-expressions/src/FunctionExpression.spec.ts) appear to be Red Herrings, not actually testing if a expression works past weather it will accept parameters

(d) there also appear to be no put tests in packages/dynamodb-data-mapper/src/DataMapper.spec.ts only available for delete & query methods

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions