[BUGFIX] dbal: return NULL/NOT NULL information in admin_get_fields() 51/40051/4
authorMorton Jonuschat <yabawock@gmail.com>
Sat, 6 Jun 2015 14:03:35 +0000 (16:03 +0200)
committerXavier Perseguers <xavier@typo3.org>
Wed, 10 Jun 2015 07:43:22 +0000 (09:43 +0200)
MySQL returns a YES/NO string for every field to determine if NULL values
are allowed in the field. The DBAL version of admin_get_fields always
returned an empty string although the required details are returned by
ADOdb drivers. Make this information available.

Resolves: #67298
Releases: master
Change-Id: I6892783aced1e574cb6f5702da067f4e6e867529
Reviewed-on: http://review.typo3.org/40051
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Xavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers <xavier@typo3.org>
typo3/sysext/dbal/Classes/Database/Specifics/AbstractSpecifics.php

index aac5f4a..bb5154b 100644 (file)
@@ -83,7 +83,7 @@ abstract class AbstractSpecifics {
 
                $fieldRow['Field'] = $fieldRow['name'];
                $fieldRow['Type'] = strtolower($mysqlType);
-               $fieldRow['Null'] = '';
+               $fieldRow['Null'] = $this->getNativeNotNull($fieldRow['not_null']);
                $fieldRow['Key'] = '';
                $fieldRow['Default'] = $fieldRow['default_value'];
                $fieldRow['Extra'] = '';
@@ -221,4 +221,14 @@ abstract class AbstractSpecifics {
                                return '(' . $maxLength . ')';
                }
        }
+
+       /**
+        * Return the MySQL native representation of the NOT NULL setting
+        *
+        * @param mixed $notNull
+        * @return string
+        */
+       protected function getNativeNotNull($notNull) {
+               return (bool)$notNull ? 'NO' : 'YES';
+       }
 }