- This topic has 3 replies, 2 voices, and was last updated 6 years, 10 months ago by .
Viewing 3 reply threads
Viewing 3 reply threads
- You must be logged in to reply to this topic.
Hi,
In my ORM object I have some fields defined as a kbmMWNullable<integer> type. I use this object in a smartservice (REST). When I do a http get request I do get null values in my json if I however want to do a post with these same values I see in the kbmm log that the null value is converted to zero instead of null.
Is this a bug or am I doing something wrong here and should I for instance use the NullValue attribute instead?
I am using kbmmw Ent 5.06.20 ( I am still waiting for my SAU being activated 😉 )
Kind regards,
Luigi
Hi,
If you send a JSON value that do not contain those fields it essentially indicates the fields to be null. In such case kbmMW should provide the value of null to you too.
However if you just print the value of the field, it will use its default native value which is 0.
eg.
FMyField:kbmMWNullable<integer>;
If you writeln(FMyField) then it will show 0 since thats the default value of an integer.
Instead you will want to check:
If FMyField.IsNull then
writeln(‘its null’);
I am not sure if I understand you correctly. Are you saying that just the visual output of a null value is zero (in case of an integer) or that the value will be zero? When reading my postgres logs I think it’s the second, but that doesn’t make sense to me because both JSON an the database can take care of null.
(seems my reply went lost in cyberspace, so 2.nd attempt)
Hi,
I say that if you have MyValue:kbmMWNullable<integer> and it is not set from anywhere then IntToStr(MyValue) will return ‘0’. However MyValue.IsNull will return true.
So if you assign MyValue to another variable (or argument) of type that is not kbmMWNullable, it will assume the value 0.