Skip to content

m2mBatchInsert throws "has no id yet" for an entity deleted mid-flush#1895

Open
allangsilva wants to merge 1 commit into
mainfrom
repro-m2m-created-then-deleted-issue
Open

m2mBatchInsert throws "has no id yet" for an entity deleted mid-flush#1895
allangsilva wants to merge 1 commit into
mainfrom
repro-m2m-created-then-deleted-issue

Conversation

@allangsilva

Copy link
Copy Markdown
Collaborator

If an entity is deleted during a reaction after it's been hooked and after it was linked into a m2m, the pending join row isn't pruned. It survives into m2mBatchInsert, which then reads the deleted entity's idTagged, but the entity was never inserted (created-then-deleted), so it has no id:

 Tag has no id yet
   at failNoIdYet (core/src/index.ts:296)
   at m2mBatchInsert (orm/src/drivers/PostgresDriver.ts:262)

@allangsilva allangsilva requested a review from stephenh June 22, 2026 20:34
id?: ValueGraphQLFilter<BookId>;
title?: ValueGraphQLFilter<string>;
author?: EntityGraphQLFilter<Author, AuthorId, GraphQLFilterOf<Author>, never>;
authorId?: ValueGraphQLFilter<AuthorId>;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure why I got so many codegen changes, just did yarn db 🤔

@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

joist-codegen

npm i https://pkg.pr.new/joist-orm/joist-orm/joist-codegen@1895

joist-core

npm i https://pkg.pr.new/joist-orm/joist-orm/joist-core@1895

joist-graphql-codegen

npm i https://pkg.pr.new/joist-orm/joist-orm/joist-graphql-codegen@1895

joist-graphql-resolver-utils

npm i https://pkg.pr.new/joist-orm/joist-orm/joist-graphql-resolver-utils@1895

joist-knex

npm i https://pkg.pr.new/joist-orm/joist-orm/joist-knex@1895

joist-migration-utils

npm i https://pkg.pr.new/joist-orm/joist-orm/joist-migration-utils@1895

joist-orm

npm i https://pkg.pr.new/joist-orm/joist-orm@1895

joist-test-utils

npm i https://pkg.pr.new/joist-orm/joist-orm/joist-test-utils@1895

joist-utils

npm i https://pkg.pr.new/joist-orm/joist-orm/joist-utils@1895

commit: c6ab044

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.

2 participants