Convert to/from NULL value in Database

Convert to/from NULL value in Database

  

hi there, I use external mysql and in the Integration Studio find this feature:

I am wondering what the "Convert to/from NULL value in Database" means? 

I try to insert -99999999 and it is inserted as NULL in db - as I guess, not 0 (Outsystems null).

Then i open entity of that table in the outsystems, it shows 0, NOT -9999999 that I guess, because the  phrase above said to/from null, so i guess it will results -999999999. Is it correct behavior or else?

many thanks

Hi Box,

In OutSystems, the value will never be NULL, even if when you save the data in the external entity, it saves NULL.
Inn OutSystems, an integer that in DB is NULL will be read as 0, a NULL string as an empty string "", a NULL boolean as False, and so on.

Cheers.

EDIT. By the way, I don't think the extension is able to make a conversion FROM text to DECIMAL, implicitly (never tried). So, It seems to me that the problem of not saving -99999999 can be the fact that you are defining a default value as text when the original data type is decimal...

Hi Edu,

Thank you. So i misundertand that phrase  "Default Value behaviour: Convert to/from NULL value in Database" , i am thinking when it is saved NULL to database (Convert to-correct as i guess), when i read it back in the Outsystems, it will be the default value (-999999999 Convert from - incorrect what i guess).


regards

Yap.

When saving a record, if you don't provide a value, it will save NULL, instead of the data type default value.
When reading a field that has NULL, it will convert back.

Normally, if you don't set this, OutSystems will use the default value as value if you don't provide one.

Cheers.

But the behavior is not like that..when i read that null, it returns 0, instead of -9999999

Hi Box,

This is from documentation:

Indicates how the default values of the entity's attributes are stored in the database and retrieved from the database:

No conversion to/from Database : all the entity's attributes that have the default value set are stored in and retrieved from the database without any conversion, i.e., it is the default value that is stored in and retrieved from the database.

Convert to/from Null value in Database
: all the entity's attributes that have the default value set are stored in the database with the null value. When retrieving data from the database, the null value is converted to the attribute's default value. If no default value is defined for the attribute,  the null value is then converted to the Platform default value for the data type.

So, if you set Convert to/from Null value, when reading a record that has a NULL, it should come with the default value defined, OR with the datatype default value.

I just tested, in a situation very similar to yours, and it is working as expected.
For NULL values, it is bringing back the default value defined.

Could be the case that you changed the option later and that the value in the record is NOT null, but 0?

Thank you fo the document Sir. I'll retry later to validate the document.. i m using external db mysql..and after insert -999999999 in the db it becomes null db. Then i use aggregate to see that row.. unfortunately..it is 0.. but i ll retry.. 

Hi Sir,

Given:

I have retried, just insert the value -99999 using createEntity, 



it is saved as NULL in the physical table (as i guess):

However, when i see the row in an entity, the result is NOT as expected, instead of -99999, it gives null:

regards