Skip to content

Include related models: bug if foreign key is null #4332

@eliaoucohen72

Description

@eliaoucohen72

Hello,
I am using loopback 4 for my server side. I built my models with the new inclusion functionality.
I have model A and model B, In model A, there is a foreign key of model B. When I make a get request, I get the information with the whole object of the foreign key. Everything works perfectly but ... my foreign key is not required. So, when I make a get request in case the foreign key is null, I get the following error:

DEFAULT is not allowed in this context on Connection.parseE ...

This problem only exists if in the database there are rows where the fk is null and another where the fk is not null.
For example:

id: 1,
name: "aaaa",
modelb_id: null

id: 2,
name: "bbb",
modelb_id: 1

I mean if in all the rows the fk is null, everything works perfectly.

Anyone knows a solution ???
Thank you

Metadata

Metadata

Assignees

Labels

RelationsModel relations (has many, etc.)db:PostgreSQLTopics specific to PostgreSQL

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions