orbit icon indicating copy to clipboard operation
orbit copied to clipboard

Empty many to many relationships cause an exception

Open johncarter- opened this issue 3 years ago β€’ 4 comments

When accessing empty model many to many relationships you get a SQLSTATE[HY000]: General error: 1 no such table: the_pivot_table_name exception.

How to replicate

  1. Clone https://github.com/johncarter-/laravel-orbit-many-to-many

  2. Switch to the issue/many-to-many-no-such-table branch.

  3. Run php artisan test --filter it_can_handle_empty_many_to_many_relationships tests/Feature/OrbitalManyToManyTest.php

johncarter- avatar Apr 02 '22 12:04 johncarter-

If you create then delete a pivot model to sort of "initialise" the "table"/directory it works. See the follow up test in that branch.

I took a bit of source dive 🀿, but after a while trying to figure it out I didn't know my arse from my elbow. πŸ€·β€β™‚οΈ

johncarter- avatar Apr 04 '22 19:04 johncarter-

@johncarter- Yeah, the codebase is a bit messy right now. My 2.x branch is much cleaner, I think. This might be something I put on hold fixing until then though, it'll probably be a couple of weeks.

Do you need this functionality for a project right now?

ryangjchandler avatar Apr 04 '22 19:04 ryangjchandler

Oh I didn't mean there was anything wrong with your code 😯 I just meant I was in over my head.

I can use the create and delete workaround for now, no pressure at allπŸ‘Œ

johncarter- avatar Apr 04 '22 20:04 johncarter-

@johncarter- Sweet!

ryangjchandler avatar Apr 04 '22 20:04 ryangjchandler