View Issue Details

IDProjectCategoryView StatusLast Update
0006914OXID eShop (all versions)4.01. Database handlingpublic2018-10-25 10:17
Reporterpbenke 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version6.1.0 
Target VersionFixed in Version 
Summary0006914: Incorrect default values from database-columns, if empty
DescriptionFor the following example, a database column with default '' is needed, e.g.
vendor/oxid-esales/oxideshop-ce/source/Setup/Sql/database_schema.sql:

CREATE TABLE `oxuser` (
  ...
  `OXSTREET` varchar(255) NOT NULL default '' COMMENT 'Street',


So, if the function metaColumns is called:

vendor/oxid-esales/oxideshop-ce/source/Core/Database/Adapter/Doctrine/Database.php
=> public function metaColumns($table)

There is the following code (Line 1112):

$item->has_default = ('' === $default || is_null($default)) ? false : true;

But, the following statement:

SELECT
COLUMN_NAME AS `Field`,
COLUMN_TYPE AS `Type`,
IS_NULLABLE AS `Null`,
COLUMN_KEY AS `Key`,
COLUMN_DEFAULT AS `Default`,
EXTRA AS `Extra`,
COLUMN_COMMENT AS `Comment`,
CHARACTER_SET_NAME AS `CharacterSet`,
COLLATION_NAME AS `Collation`
FROM information_schema.COLUMNS
WHERE
TABLE_SCHEMA = 'db'
AND
TABLE_NAME = 'oxuser'

gives this result:

OXSTREET | varchar(255) | NO | '' | Street | utf8 | utf8_general_ci

=> Default value is '' and not empty!

=> So the code above does not match.
This would be correct:

$item->has_default = ("''" === $default || '' === $default || is_null($default)) ? false : true;

TagsDatabase
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
MySQL VersionNot defined

Relationships

related to 0006888 closed Wrong default value of columns is read on mariadb 10.2.7 and higher 

Activities

QA

2018-10-25 10:14

administrator   ~0012662

That's a bit tricky.

One person would say: Yes. A empty string ('' or "") is not "empty" in the terms of null, so it is just a zero character long string and therefore not false.
Another person would say: Because of the "not null" information (so the field must have any kind of content) an empty string has to be interpreted as null and is therefore false.

Because of this I will acknowledge this entry so our Productmanager can decide if it's correct as it currently is or if the if clause has to be adopted according your proposal.

-MK