1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | commit ae0ca945d1ad39f5b2ca1efa804de964129f025e Author: Christian Weiske <weiske@mogic.com> Date: Fri Jan 22 10:57:21 2021 +0100 Support POINT SQL data type in TYPO3 core v8.7 diff --git typo3/sysext/core/Classes/Database/ConnectionPool.php typo3/sysext/core/Classes/Database/ConnectionPool.php index 8f81e615..1b038cb9 100644 --- typo3/sysext/core/Classes/Database/ConnectionPool.php +++ typo3/sysext/core/Classes/Database/ConnectionPool.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Database\Schema\EventListener\SchemaColumnDefinitionListener; use TYPO3\CMS\Core\Database\Schema\EventListener\SchemaIndexDefinitionListener; use TYPO3\CMS\Core\Database\Schema\Types\EnumType; +use TYPO3\CMS\Core\Database\Schema\Types\PointType; use TYPO3\CMS\Core\Database\Schema\Types\SetType; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -54,6 +55,7 @@ class ConnectionPool */ protected $customDoctrineTypes = [ EnumType::TYPE => EnumType::class, + PointType::TYPE => PointType::class, SetType::TYPE => SetType::class, ]; diff --git typo3/sysext/core/Classes/Database/Schema/Parser/AST/DataType/PointDataType.php typo3/sysext/core/Classes/Database/Schema/Parser/AST/DataType/PointDataType.php new file mode 100644 index 00000000..0222357e --- /dev/null +++ typo3/sysext/core/Classes/Database/Schema/Parser/AST/DataType/PointDataType.php @@ -0,0 +1,32 @@ +<?php +declare(strict_types = 1); + +namespace TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType; + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +/** + * Node representing the POINT SQL column type + */ +class PointDataType extends AbstractDataType +{ + /** + * BlobDataType constructor. + */ + public function __construct() + { + // MySQL BLOB can store 64KB + $this->length = 65535; + } +} diff --git typo3/sysext/core/Classes/Database/Schema/Parser/Lexer.php typo3/sysext/core/Classes/Database/Schema/Parser/Lexer.php index 2222583f..5d106b6d 100644 --- typo3/sysext/core/Classes/Database/Schema/Parser/Lexer.php +++ typo3/sysext/core/Classes/Database/Schema/Parser/Lexer.php @@ -78,6 +78,8 @@ class Lexer extends \Doctrine\Common\Lexer\AbstractLexer const T_SET = 231; const T_JSON = 232; + const T_POINT = 240; + // All keyword tokens should be >= 300 const T_CREATE = 300; const T_TEMPORARY = 301; diff --git typo3/sysext/core/Classes/Database/Schema/Parser/Parser.php typo3/sysext/core/Classes/Database/Schema/Parser/Parser.php index 3986fa23..a83714fd 100644 --- typo3/sysext/core/Classes/Database/Schema/Parser/Parser.php +++ typo3/sysext/core/Classes/Database/Schema/Parser/Parser.php @@ -970,6 +970,10 @@ protected function columnDataType(): AST\DataType\AbstractDataType $this->match(Lexer::T_JSON); $dataType = new AST\DataType\JsonDataType(); break; + case Lexer::T_POINT: + $this->match(Lexer::T_POINT); + $dataType = new AST\DataType\PointDataType(); + break; default: $this->syntaxError( 'BIT, TINYINT, SMALLINT, MEDIUMINT, INT, INTEGER, BIGINT, REAL, DOUBLE, FLOAT, DECIMAL, NUMERIC, ' . diff --git typo3/sysext/core/Classes/Database/Schema/Parser/TableBuilder.php typo3/sysext/core/Classes/Database/Schema/Parser/TableBuilder.php index 3ce00198..a04f360b 100644 --- typo3/sysext/core/Classes/Database/Schema/Parser/TableBuilder.php +++ typo3/sysext/core/Classes/Database/Schema/Parser/TableBuilder.php @@ -31,6 +31,7 @@ use TYPO3\CMS\Core\Database\Schema\Parser\AST\IndexColumnName; use TYPO3\CMS\Core\Database\Schema\Parser\AST\ReferenceDefinition; use TYPO3\CMS\Core\Database\Schema\Types\EnumType; +use TYPO3\CMS\Core\Database\Schema\Types\PointType; use TYPO3\CMS\Core\Database\Schema\Types\SetType; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -372,6 +373,9 @@ protected function getDoctrineColumnTypeName(DataType\AbstractDataType $dataType // Using a SMALLINT covers the value range and ensures database compatibility. $doctrineType = SetType::SMALLINT; break; + case DataType\PointDataType::class: + $doctrineType = PointType::TYPE; + break; default: throw new \RuntimeException( 'Unsupported data type: ' . get_class($dataType) . '!', diff --git typo3/sysext/core/Classes/Database/Schema/Types/PointType.php typo3/sysext/core/Classes/Database/Schema/Types/PointType.php new file mode 100644 index 00000000..540f6bc2 --- /dev/null +++ typo3/sysext/core/Classes/Database/Schema/Types/PointType.php @@ -0,0 +1,50 @@ +<?php +declare(strict_types = 1); +namespace TYPO3\CMS\Core\Database\Schema\Types; + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Types\Type; + +/** + * Type that maps an TYPE field. + */ +class PointType extends Type +{ + const TYPE = 'point'; + + /** + * Gets the SQL declaration snippet for a field of this type. + * + * @param array $fieldDeclaration The field declaration. + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform The currently used database platform. + * + * @return string + */ + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string + { + return 'POINT'; + } + + /** + * Gets the name of this type. + * + * @return string + */ + public function getName(): string + { + return static::TYPE; + } +} |