question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

One-to-one navigation properties with value null

See original GitHub issue

Hello cloud-sdk-js,

I have a question concerning one-to-one navigation properties. Depending on the data they can be null although this is not specified in their type definition.

Example (@sap-cloud-sdk/core 1.39.0, @sap/cloud-sdk-op-vdm-business-partner-service 1.24.0):

const destination = getDestinationFromSomewhere();
const result = await BusinessPartner
	.requestBuilder()
	.getAll()
	.execute(destination);

If customer/supplier is not maintained the corresponding one-to-one navigation properties toCustomer and toSupplier are null which does not match their type definition:

/**
* One-to-one navigation property to the [[Customer]] entity.
*/
toCustomer: Customer;
/**
* One-to-one navigation property to the [[Supplier]] entity.
*/
toSupplier: Supplier;

This may cause problems when using the result in the BusinessPartner.builder().fromJson method because it would only accept Customer/Supplier or undefined.

Could you please have a look at this?

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ja-necommented, Mar 29, 2021

Hi @jjtang1985, thanks for notifying about the fix. I’ve successfully tested with the canary version. Best regards, ja-ne

1reaction
jjtang1985commented, Mar 26, 2021

Hi @ja-ne , the PR #1141 has been merged and you’ll find it in the next stable release. Please note, the fix contains two parts:

  1. The @sap-cloud-sdk/core, which contains the fix of fromJson for the runtime error. This might be released next week.
  2. The @sap/cloud-sdk-vdm-*, which contains the type-safe clients (type error at compile time). This might take a while for a new release.

For the time being, you can already test the canary version of @sap-cloud-sdk/core, which contains the fix. Please let know if it helps if possible.

Best, Junjie

Read more comments on GitHub >

github_iconTop Results From Across the Web

EF Core 3.1.4 Navigation property returning null in One-To ...
I am having a problem where a navigation property is always returning null in a One-to-One relationship in EF Core 3.1.4.
Read more >
Relationships - EF Core | Microsoft Learn
The most common pattern for relationships is to have navigation properties defined on both ends of the relationship and a foreign key ...
Read more >
Entity Framework Core One To Many Relationships Conventions
The easiest way to configure a one-to-many relationship is by convention. EF Core will create a relationship if an entity contains a navigation...
Read more >
ef core one-to-one property is always null-entityframework core
Entity Framework Core Set null one property of entity · Navigation property is always null when using Include with EF Core · EF...
Read more >
Empty instance instead of null returned for owned navigation ...
HasOne relationship (AnAggregateRoot.AnEntity) => owner is returning null for the navigation property (works as expected). OwnsOne relationship ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found