View Issue Details

IDProjectCategoryView StatusLast Update
0007052OXID eShop (all versions)4.01. Database handlingpublic2019-11-19 22:44
Status newResolutionreopened 
Product Version6.2.0-rc.1 
Target VersionFixed in Version 
Summary0007052: DB 'NULL' value for DB float/double types not possible
Descriptionwhy are you deleting my entrie?
so if i am wrong you can say it!

but you can't set DB NULL value for float,double types in MySQL

because of:
protected function _setFieldData($fieldName, $fieldValue, $dataType = Field::T_TEXT)
        $longFieldName = $this->_getFieldLongName($fieldName);
        //$sLongFieldName = $this->_sCoreTable . "__" . strtolower($sFieldName);
        // doing this because in lazy loaded lists on first load it is harmful to have initialised fields but not yet set
        // situation: only first article is loaded fully for "select oxid from oxarticles"
        //if ($this->_blUseLazyLoading && !isset($this->$sLongFieldName))
        // return;
        //in non lazy loading case we just add a field and do not care about it more
        if (!$this->_blUseLazyLoading
            && !$this->isPropertyLoaded($longFieldName)
        ) {
            $fieldsList = $this->_getAllFields(true);
            if (isset($fieldsList[strtolower($fieldName)])) {
                $this->_addField($fieldName, $this->_getFieldStatus($fieldName));
        // if we have a double field we replace "," with "." in case somebody enters it in european format
        $isPropertyLoaded = $this->isPropertyLoaded($longFieldName);
        if ($isPropertyLoaded
            && isset($this->$longFieldName->fldtype)
            && $this->$longFieldName->fldtype == 'double'
++ && $fieldValue !==null
        ) {
            $fieldValue = str_replace(',', '.', $fieldValue);

if you think that I am wrong , please let me know and all the others, too
TagsNo tags attached.
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
MySQL VersionNot defined


related to 0007049 closedQA DB 'NULL' value for DB float/double types not possible 



2019-11-19 00:44

reporter   ~0013047

so again, the extra check, if new value is set to 'NULL' can not hurt performance or everythign else.
I am using php 7.3 for testing
and if I do not check this - the str_replace will causes a '0' instead of 'NULL' in DB mysql


2019-11-19 08:21

administrator   ~0013048

Last edited: 2019-11-19 08:21

View 2 revisions

the bug entry was not simply closed, but set to unable to reproduce with the following comment:

Can‘t reproduce the behavior.
If I add a new column with type float NULL and add as described:

$aParams[oxcountry__oxnix] = 2;

Then I have OXINIX 2 in the field. If I changed the line to save with null afterwards, I also get NULL in the database field.

It seems to be more of a DB problem/configuration/non-supported DB.
Can you reproduce that with 6.1.x?

If you still have something to comment, please always reply to the first entry made, so as not to create a lot of duplicates.

- es -


2019-11-19 09:42

reporter   ~0013049

php > $t=null;
php > echo $t===null?"y":"n";
php > echo (str_replace("d","c",$t)===null)?"y":"n";


2019-11-19 10:49

administrator   ~0013050

Last edited: 2019-11-19 10:56

View 3 revisions

Hi timwetter,

to be able to reproduce the issue described by your first entry (0007049) the form of the country main template (country_main.tpl) has to be extended with the input field for the new column oxnix. This point is missing in your description. If there is an input field in the backend, then the shop will always write a 0 instead of null. As the summary of the entry 0007049 states.
But when I add your code for the method CountryMain.php then the framework will of course write NULL, as the code overwrites the value from the form. Which is contradictory to the summary as it shows that the framework is able to write NULL to float fields.

As it is not clear if you wanted to report if either the framework does not allow NULL in float fields or that the framework uses 0 instead of null, I suggest that you simply create a Pull Request for that case, as the first claim is not reproducible and the second is more a feature request than a bug:

Thank you!

- MK


2019-11-19 22:44

reporter   ~0013051

the framework does allow NULL in DB float fields, BUT saves 0 instead of null to DB!

And if you take your time and see why that is the case, then you can clearly see that this behavior was not intended.
Why should only fields of the type float not be able to assume the value 'null'?

1) this shows, that a null value as input will be converted to an empty string via str_replace
php > $t = null;
php > var_dump($t);
php > $t = str_replace('','',$t);
php > var_dump($t);
string(0) ""
php >

the function _setFieldData will do the same with a $fieldValue=null and fldtype == 'double'

function _getUpdateFieldValue in BaseModel:
if ((null === $fieldValue)) {
            if ($this->_canFieldBeNull($fieldName)) {
                return 'null';
function _canFieldBeNull would return true, but will never be entered, because value of $fieldValue is an empty string and !== null, but original value was null