View Issue Details

IDProjectCategoryView StatusLast Update
0006914OXID eShop (all versions)4.01. Database handlingpublic2020-05-25 12:16
Reporterpbenke Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version6.1.0 
Fixed in Version6.2.0-beta.1 
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
Database VersionNot defined

Relationships

related to 0006888 resolvedanton.fedurtsya 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

pbenke

2019-01-18 15:51

reporter   ~0012768

You can close this ticket.
This behaviour only happens with a MARIA-DB >= 10.2.*:
If you use an older Doctrine version with a newer MARIA-DB version...

Thank you.

alfredbez

2019-06-06 15:43

reporter   ~0012908

I think most people agree that an empty string means no value instead of the 2 char-long string ''.

We're already checking if the default value is an empty string here:

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

QA

2020-05-25 12:16

administrator   ~0013242

https://github.com/OXID-eSales/oxideshop_ce/blob/v6.5.5/CHANGELOG.md#fixed-5
https://github.com/OXID-eSales/oxideshop_ce/pull/709
-MK