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

fix: Error when using with when the child references a parent but not using the parent's id column, but rather another column that is a unique index. #1902

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

joc-a
Copy link
Collaborator

@joc-a joc-a commented Nov 27, 2023

  • When a column in a child table references a column in the parent table that is not of type EntityID, a "is not in record set" error occurs because entities.groupBy { it.readValues[parentTable.id] } should be entities.groupBy { it.readValues[refColumn] } instead.
  • After that was fixed, when we loop over the entities grouped by refColumn, we attempt to store the referenced column value in the cache, which does not compile because it's not the right type expected by cache.getOrPutReferrers, so we need to find the parent entity that matches the value of the refColumn and use its entityId to store it in the cache.
  • The last step was to fix the invocation of findById, which was being invoked on this, which is the child entity, using id as EntityID<ID> which is for the parent entity. The fix is to find the child entity by using refColumn, which is the column in the child table that references the id in the parent table.

…ot using the parent's id column, but rather another column that is a unique index.
@joc-a joc-a marked this pull request as ready for review November 27, 2023 23:30
@joc-a joc-a requested review from bog-walk and e5l November 27, 2023 23:31
@joc-a joc-a merged commit 39544c3 into main Nov 28, 2023
5 checks passed
@joc-a joc-a deleted the joc/fix-with-error-when-reference-not-entity-id branch November 28, 2023 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants