Skip to content

GSI pk sometimes not working, based on sk value, can't understand why #524

@pablote

Description

@pablote

Maybe there's an explanation for this, but I can't understand why or if it's a bug.

If I set my indexes like these:

{ indexes: {
      byKey: {
        pk: {
          field: "pk",
          composite: ["id"],
        },
        sk: {
          field: "sk",
          composite: ["createdAt"],
        },
      },
      byUserId: {
        index: "gsi1pk-gsi1sk-index",
        pk: {
          field: "gsi1pk",
          composite: ["requestUserId"],
        },
        sk: {
          field: "gsi1sk",
          composite: ["createdAt"],
        },
      },
    }
}

For some reason gsi1pk doesn't save the value for the field, even though there is one:

Image

Now, if I change the value of gs1sk to some other property, like "requestPath", now gsi1pk works:

Image

I thought this might be related with "createdAt" being used in the primary index, but it also doesn't work if I use "updatedAt" in the gsi1sk:

Image

Maybe this is something about dates, idk, but if I add a new property "timestamp" which I load with the same exact value as "createdAt", then it works again:

Image

Can anyone please help understand what's going on? Seems to be bug, but I can't be sure, thanks.

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