View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006914 | OXID eShop (all versions) | 4.01. Database handling | public | 2018-10-24 10:39 | 2020-05-25 12:16 |
Reporter | pbenke | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 6.1.0 | ||||
Fixed in Version | 6.2.0-beta.1 | ||||
Summary | 0006914: Incorrect default values from database-columns, if empty | ||||
Description | For 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; | ||||
Tags | Database | ||||
Theme | Not defined | ||||
Browser | Not defined | ||||
PHP Version | Not defined | ||||
Database Version | Not defined | ||||
related to | 0006888 | resolved | anton.fedurtsya | Wrong default value of columns is read on mariadb 10.2.7 and higher |
|
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 |
|
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. |
|
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; |
|
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 |