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

Composite unique index appears to ignore datetime components #2914

Closed
AndrewSisley opened this issue Aug 15, 2024 · 0 comments · Fixed by #2933
Closed

Composite unique index appears to ignore datetime components #2914

AndrewSisley opened this issue Aug 15, 2024 · 0 comments · Fixed by #2933
Assignees
Labels
area/query Related to the query component bug Something isn't working

Comments

@AndrewSisley
Copy link
Contributor

AndrewSisley commented Aug 15, 2024

Found by David.

Schema:

type PlayerAction @index(unique: true, fields: ["action_id", "player_id", "createdAt"], name: "action_unqiue") {
  metadata: JSON
  deleted: Boolean
  action: Action @relation(name: "actionPlayerActions")
  player: Player @relation(name: "playerPlayerActions")
  playerRewards: [PlayerActionToPlayerReward] @relation(name: "playerActionPlayerRewards")
  createdAt: DateTime
}

The below error is returned when creating a document with matching action_id and player_id, but a different createdAt value:

"can not index a doc's field(s) that violates unique index. DocID: bae-c90ee0a1-5abc-53f5-b252-ae47531c76e9, action_id: bae-c0a5a3a4-2fdb-583f-ab9f-0646e28922e2, player_id: bae-52a9e176-d69e-57d4-b28a-d57a9de275b7, createdAt: 2024-02-15 16:22:03.641 +0000 UTC"

@AndrewSisley AndrewSisley added bug Something isn't working area/query Related to the query component labels Aug 15, 2024
@islamaliev islamaliev self-assigned this Aug 20, 2024
islamaliev added a commit that referenced this issue Aug 20, 2024
## Relevant issue(s)

Resolves #2914

## Description

Make indexes handle time.Time type as well.
For this encoding/decoding of time type is added to encoding package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/query Related to the query component bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants