micronaut-data icon indicating copy to clipboard operation
micronaut-data copied to clipboard

Product.kt example — remove nullable type on association property

Open avarun42 opened this issue 3 years ago • 5 comments

Manufacturer? -> Manufacturer

If you look at the docs in https://github.com/micronaut-projects/micronaut-data/blob/master/src/main/docs/guide/sql/dbc/sqlMapping/sqlAssociationFetching.adoc, they state:

an exception will occur since the manufacturer association is not Nullable.

Then state to solve this by:

in Kotlin add ? to the end of the constructor argument name

However the example already is nullable and has a ? at the end of the property type. This seems to be a mistake.

avarun42 avatar Mar 10 '22 00:03 avarun42

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Mar 10 '22 00:03 CLAassistant

It looks like it failed with Null can not be a value of a non-null type Manufacturer

dstepanov avatar Mar 18 '22 08:03 dstepanov

It looks like it failed with Null can not be a value of a non-null type Manufacturer

From my reading of this section of the docs though, it seems like this example snippet is supposed to throw an exception of this kind.

If you look at the Java example for the same section, the manufacturer relation is explicitly not marked as nullable. The Kotlin example isn't consistent with the Java example or with the written docs themselves.

avarun42 avatar Apr 07 '22 19:04 avarun42

If somebody can point me to where to update the test to expect a thrown exception I can update this PR.

avarun42 avatar May 22 '23 03:05 avarun42

Can you rebase it and force push? So we will have a fresh run and see what test was failing.

dstepanov avatar May 30 '23 13:05 dstepanov