Skip to content

Belongs-To relation tries to resolve for foreign key NULL #4372

@deepakrkris

Description

@deepakrkris

Steps to reproduce

Detailed steps are in issue #4332

Current Behavior

Belongs-To resolver tries to fetch objects for foreign keys by constructing an IN clause (the juggler does this on behalf of the resolver). If a foreign key has NULL value the constructed IN clause has a NULL value in it. This may result in errors in certain conditions Edit: This is causing failures in Postgres (issue #4332). When Postgres queries with null value id, it throws: error: DEFAULT is not allowed in this context.

Expected Behavior

NULL values in foreign keys need not be queried (edit) or should be handled well as MySQL does, unless we are allowing for logical relations to be defined where the foreign key is just a string value and may not refer to a primary key of another table.

Link to reproduction sandbox

Provided in issue #4332

Acceptance criteria

  • Fix Postgres connector to handle the case when null values are passed in
    • example: Order {id: 1, customerId: null}, {id: 2, customerId: 1}. When traverse Order with inclusion, Postgres should handle the null fk properly.
  • fix querying related entities with null keys and add related tests to repository-test
  • check if Mongo and MySQL connectors handles this case.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions