Home Forums kbmMW kbmMWNullable

This topic contains 3 replies, has 2 voices, and was last updated by  kimbomadsen 6 months, 2 weeks ago.

  • Author
  • #53508



    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,


    • This topic was modified 6 months, 2 weeks ago by  mrluigi2017.
  • #53512



    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.



    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’);


  • #53514


    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.

  • #53515


    (seems my reply went lost in cyberspace, so 2.nd attempt)


    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.



You must be logged in to reply to this topic.