orm icon indicating copy to clipboard operation
orm copied to clipboard

MorphMany relation cannot be accessed right after parent model `create`

Open os-nikita opened this issue 2 years ago • 1 comments

Describe the bug

foo = Foo.create({...})
foo.some_morph_many_relation # AttributeError: class model 'Foo' has no attribute some_morph_many_relation

# but:
foo = foo.fresh() # after create
foo.some_morph_many_relation # works fine

Additional context Might be related to https://github.com/MasoniteFramework/orm/issues/750

os-nikita avatar Jul 08 '22 12:07 os-nikita

This was the cause of this issue: https://github.com/MasoniteFramework/masonite/issues/693

I thought that it was tests framework related somehow, but it's the same thing. The @morph_many relation isn't usable right after a create.

os-nikita avatar Jul 18 '22 17:07 os-nikita