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

owner likely unsaved, attach within attach closure #586

Closed
wibed opened this issue Sep 18, 2023 · 2 comments
Closed

owner likely unsaved, attach within attach closure #586

wibed opened this issue Sep 18, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@wibed
Copy link

wibed commented Sep 18, 2023

related to recent pr:
#585

mentionable:

  • database is a transaction here

code:

    try await event.$account.attach(Account, on: database, { roster in
      try await roster.$promise.attach(Promise, on: database) })
[Vapor] siblings relation Siblings<Roster, Promise, RosterPromise>
(from: [roster_id], to: [promise_id]) is missing owning model's ID (owner likely unsaved)
@wibed wibed added the bug Something isn't working label Sep 18, 2023
@gwynne
Copy link
Member

gwynne commented Sep 18, 2023

Right - the roster model hasn't been saved yet while you're still editing it, so you can't use the attach methods on it unless you manually allocate an ID for it and assign that ID to the model before returning from the closure.

@wibed
Copy link
Author

wibed commented Sep 18, 2023

thanks for the clarification!

@wibed wibed closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants