Skip to content

Dot notation causes different behaviour #15

@benswinburne

Description

@benswinburne

If I run the following update, the dots are expanded in the key (but dots in keys are perfectly valid in DDB). Whilst it'd be nice to be able to not expand dots using a configuration, it's highlighted some behaviour I'm not sure is correct.

If I use the dot notation,

{
	"client": {
		"test.dot": "foo"
	}
}

The following update expression is created

{ UpdateExpression: 'SET #client.#test.#dot = :clienttestdot',
  ExpressionAttributeNames: { '#client': 'client', '#test': 'test', '#dot': 'dot' },
  ExpressionAttributeValues: { ':clienttestdot': 'foo' } }

Which fails if client.test doesn't already exist (It works fine if client.test.dot exists already)

The document path provided in the update expression is invalid for update

But if I structure the update per the below example

{
	"client": {
		"test": {
			"dot": "foo"
		}
	}
}

This results in the following update expression which is clearly different to the previous one.

{ UpdateExpression: 'SET #client.#test = :clienttest',
  ExpressionAttributeNames: { '#client': 'client', '#test': 'test' },
  ExpressionAttributeValues: { ':clienttest': { dot: 'foo' } } }

This update works regardless of client.test existing prior to the update.

Is this expected behaviour?

Also, how might I save a key with a dot in it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions