diff --git a/app/etc/di.xml b/app/etc/di.xml index 308ec1ef4d6ed..177c6b67fb50b 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -1444,6 +1444,7 @@ \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\MediumText \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Text \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\StringBinary + \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\StringBinary \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\StringBinary \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Blob \Magento\Framework\Setup\Declaration\Schema\Dto\Factories\MediumBlob @@ -1591,6 +1592,7 @@ Magento\Framework\Setup\SchemaListenerDefinition\TextBlobDefinition Magento\Framework\Setup\SchemaListenerDefinition\TextBlobDefinition Magento\Framework\Setup\SchemaListenerDefinition\TextBlobDefinition + Magento\Framework\Setup\SchemaListenerDefinition\CharDefinition Magento\Framework\Setup\SchemaListenerDefinition\TimestampDefinition Magento\Framework\Setup\SchemaListenerDefinition\TimestampDefinition Magento\Framework\Setup\SchemaListenerDefinition\DateDefinition diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml index ae6c98e4627d2..9de94cf0549be 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml @@ -48,6 +48,7 @@ + diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php index a69e456ec4a8b..f2a34c338edc2 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php @@ -36,6 +36,7 @@ `longtext` longtext, `mediumtext` mediumtext, `varchar` varchar(100) DEFAULT NULL, + `char` char(255) DEFAULT NULL, `mediumblob` mediumblob, `blob` blob, `boolean` tinyint(1) DEFAULT \'1\', diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php index 01e007edb7684..0b1ec6245478b 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php @@ -38,6 +38,7 @@ `longtext` longtext, `mediumtext` mediumtext, `varchar` varchar(254) DEFAULT NULL, + `char` char(255) DEFAULT NULL, `mediumblob` mediumblob, `blob` blob, `boolean` tinyint(1) DEFAULT NULL, diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/dry_run_log.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/dry_run_log.php index e642e57701149..7735bd433d9d2 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/dry_run_log.php +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/dry_run_log.php @@ -38,6 +38,7 @@ `longtext` longtext NULL , `mediumtext` mediumtext NULL , `varchar` varchar(254) NULL , +`char` char(255) NULL , `mediumblob` mediumblob NULL , `blob` blob NULL , `boolean` BOOLEAN NULL , diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php index a064d096f6d38..0109b644e546f 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php @@ -199,6 +199,12 @@ 'type' => 'mediumtext', 'name' => 'mediumtext', ], + 'char' => [ + 'type' => 'char', + 'name' => 'char', + 'length' => '255', + 'nullable' => 'true', + ], 'varchar' => [ 'type' => 'varchar', 'name' => 'varchar', diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/StringBinary.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/StringBinary.php index 58e6df1146300..4de198ae631f4 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/StringBinary.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Columns/StringBinary.php @@ -11,7 +11,7 @@ /** * String or Binary column. - * Declared in SQL, like VARCHAR(L), BINARY(L) + * Declared in SQL, like CHAR(L), VARCHAR(L), BINARY(L) * where L - length. */ class StringBinary extends Column implements @@ -73,10 +73,9 @@ public function isNullable() } /** - * Return default value. - * Note: default value should be string. + * Return default value, Note: default value should be string. * - * @return string | null + * @return string|null */ public function getDefault() { diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd index bb9136d8a9ae6..2fbab18161925 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd @@ -20,6 +20,7 @@ + diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/types/texts/char.xsd b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/types/texts/char.xsd new file mode 100644 index 0000000000000..27ec7852b3b8d --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/types/texts/char.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + Here plain text can be persisted without trailing spaces. Length of this field can't be more than 255 characters + When CHAR values are retrieved, trailing spaces are removed unless the PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled. + + + + + + + + + + + + + + + + diff --git a/lib/internal/Magento/Framework/Setup/SchemaListenerDefinition/CharDefinition.php b/lib/internal/Magento/Framework/Setup/SchemaListenerDefinition/CharDefinition.php new file mode 100644 index 0000000000000..058ca69564871 --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/SchemaListenerDefinition/CharDefinition.php @@ -0,0 +1,29 @@ + $definition['type'], + 'name' => $definition['name'], + 'length' => $definition['length'] ?? self::DEFAULT_TEXT_LENGTH, + 'default' => isset($definition['default']) ? (bool) $definition['default'] : null, + 'nullable' => $definition['nullable'] ?? true, + ]; + } +}