Skip to content

Incorrect params for patch/update for clustered index with no sort key #412

Open
@santiagomera

Description

@santiagomera

Describe the bug
When executing a patch/update, the GSI sort key is changed from the value generated at create, causing that the entity is not returned when queried using that GSI.

At create:
image

At update:
image

When querying:
image

Because the update removed the #myentity_1 suffix from gsic1sk, the query conditions won't match and thus the entity is excluded from the query results.

ElectroDB Version
2.14.2

ElectroDB Playground Link
Playground Link

Entity/Service Definitions

const MyEntity = new Entity({
  model: {
    version: '1',
    service: 'app',
    entity: 'myEntity',
  },
  attributes: {
    id: { type: 'string', required: true },
    name: { type: 'string', required: true },
    date: { type: 'string', required: true },
  },
  indexes: {
    primary: {
      pk: { field: 'pk', composite: ['id'] },
      sk: { field: 'sk', composite: [] }
    },
    byName: {
      collection: 'names',
      type: 'clustered',
      index: 'gsic1',
      pk: { field: 'gsic1pk', composite: ['name'] },
      sk: { field: 'gsic1sk', composite: [] }
    },
    byDate: {
      collection: "dates",
      index: 'gsic2',
      pk: { field: 'gsic2pk', composite: ['date'] },
      sk: { field: 'gsic2sk', composite: [] }
    }
  }
}, { table });

Expected behavior
That the format of the GSI attributes is not altered during patch/updates.

Errors
None

Additional context

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