emmett-framework / emmett

The web framework for inventors
Other
1.03k stars 70 forks source link

Bug with fields refers_to in 2.4.8 #430

Closed josejachuf closed 2 years ago

josejachuf commented 2 years ago

This error is happening with fields refers_to, at least I think. It happens at 2.4.8 but it works fine in 2.3.1

I have two models, one that includes only belongs_to fields in addition to the basic types, in that model works fine, in the other I also have refers_to, and there it fails

ERROR in handlers [/venv/lib/python3.8/site-packages/emmett/asgi/handlers.py:340]: Application exception: Traceback (most recent call last): File "/venv/lib/python3.8/site-packages/emmett/asgi/handlers.py", line 325, in dynamic_handler http = await self.router.dispatch(ctx.request, ctx.response) File "/venv/lib/python3.8/site-packages/emmett/routing/router.py", line 249, in dispatch return await match.dispatch(reqargs, response) File "/venv/lib/python3.8/site-packages/emmett/routing/dispatchers.py", line 72, in dispatch rv = self.response_builder(await self.f(reqargs), response) File "/venv/lib/python3.8/site-packages/emmett/pipeline.py", line 328, in flow output = await pipe_method(f, kwargs) File "/venv/lib/python3.8/site-packages/emmett/pipeline.py", line 234, in pipe return await next_pipe(kwargs) File "/venv/lib/python3.8/site-packages/emmett/pipeline.py", line 328, in flow output = await pipe_method(f, kwargs) File "/venv/lib/python3.8/site-packages/emmett/tools/auth/apis.py", line 277, in pipe return await next_pipe(kwargs) File "/venv/lib/python3.8/site-packages/emmett/pipeline.py", line 369, in flow return await pipe_method(f, kwargs) File "/venv/lib/python3.8/site-packages/emmett/tools/service.py", line 28, in pipe_request return self.encoder(await next_pipe(kwargs)) File "/venv/lib/python3.8/site-packages/emmett_rest/rest.py", line 538, in _create r = self.model.new(attrs) File "/venv/lib/python3.8/site-packages/emmett/orm/models.py", line 921, in new rv._fields.update({ File "/venv/lib/python3.8/site-packages/emmett/orm/models.py", line 924, in ) if isinstance(attributes[field], StructuredRow) else typed_row_reference( File "/venv/lib/python3.8/site-packages/emmett/orm/helpers.py", line 551, in typed_row_reference return { File "/venv/lib/python3.8/site-packages/emmett/orm/helpers.py", line 120, in new rv = super().new(cls, id, *args, **kwargs) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

josejachuf commented 2 years ago

This works fine. Thanks