|
34 | 34 | use function sprintf; |
35 | 35 | use function str_replace; |
36 | 36 | use function strtolower; |
| 37 | +use function strtoupper; |
37 | 38 |
|
38 | 39 | /** |
39 | 40 | * Provides the base implementation for the lowest versions of supported MySQL-like database platforms. |
@@ -224,17 +225,27 @@ public function getBooleanTypeDeclarationSQL(array $column): string |
224 | 225 | */ |
225 | 226 | public function getGeometryTypeDeclarationSQL(array $column): string |
226 | 227 | { |
227 | | - throw NotSupported::new(__METHOD__); |
| 228 | + $geometryType = $column['geometryType'] ?? 'GEOMETRY'; |
| 229 | + $srid = $column['srid'] ?? null; |
| 230 | + |
| 231 | + $sql = strtoupper($geometryType); |
| 232 | + |
| 233 | + if ($srid !== null) { |
| 234 | + // MySQL 8.0.3+ supports SRID attribute using conditional comment syntax |
| 235 | + $sql .= sprintf(' /*!80003 SRID %d */', $srid); |
| 236 | + } |
| 237 | + |
| 238 | + return $sql; |
228 | 239 | } |
229 | 240 |
|
230 | 241 | public function getGeometryFromTextSQL(string $sqlExpr): string |
231 | 242 | { |
232 | | - throw NotSupported::new(__METHOD__); |
| 243 | + return sprintf('ST_GeomFromText(%s)', $sqlExpr); |
233 | 244 | } |
234 | 245 |
|
235 | 246 | public function getGeometryAsTextSQL(string $sqlExpr): string |
236 | 247 | { |
237 | | - throw NotSupported::new(__METHOD__); |
| 248 | + return sprintf('ST_AsText(%s)', $sqlExpr); |
238 | 249 | } |
239 | 250 |
|
240 | 251 | /** |
@@ -796,38 +807,46 @@ public function getSetTransactionIsolationSQL(TransactionIsolationLevel $level): |
796 | 807 | protected function initializeDoctrineTypeMappings(): void |
797 | 808 | { |
798 | 809 | $this->doctrineTypeMapping = [ |
799 | | - 'bigint' => Types::BIGINT, |
800 | | - 'binary' => Types::BINARY, |
801 | | - 'blob' => Types::BLOB, |
802 | | - 'char' => Types::STRING, |
803 | | - 'date' => Types::DATE_MUTABLE, |
804 | | - 'datetime' => Types::DATETIME_MUTABLE, |
805 | | - 'decimal' => Types::DECIMAL, |
806 | | - 'double' => Types::FLOAT, |
807 | | - 'enum' => Types::ENUM, |
808 | | - 'float' => Types::SMALLFLOAT, |
809 | | - 'int' => Types::INTEGER, |
810 | | - 'integer' => Types::INTEGER, |
811 | | - 'json' => Types::JSON, |
812 | | - 'longblob' => Types::BLOB, |
813 | | - 'longtext' => Types::TEXT, |
814 | | - 'mediumblob' => Types::BLOB, |
815 | | - 'mediumint' => Types::INTEGER, |
816 | | - 'mediumtext' => Types::TEXT, |
817 | | - 'numeric' => Types::DECIMAL, |
818 | | - 'real' => Types::FLOAT, |
819 | | - 'set' => Types::SIMPLE_ARRAY, |
820 | | - 'smallint' => Types::SMALLINT, |
821 | | - 'string' => Types::STRING, |
822 | | - 'text' => Types::TEXT, |
823 | | - 'time' => Types::TIME_MUTABLE, |
824 | | - 'timestamp' => Types::DATETIME_MUTABLE, |
825 | | - 'tinyblob' => Types::BLOB, |
826 | | - 'tinyint' => Types::BOOLEAN, |
827 | | - 'tinytext' => Types::TEXT, |
828 | | - 'varbinary' => Types::BINARY, |
829 | | - 'varchar' => Types::STRING, |
830 | | - 'year' => Types::DATE_MUTABLE, |
| 810 | + 'bigint' => Types::BIGINT, |
| 811 | + 'binary' => Types::BINARY, |
| 812 | + 'blob' => Types::BLOB, |
| 813 | + 'char' => Types::STRING, |
| 814 | + 'date' => Types::DATE_MUTABLE, |
| 815 | + 'datetime' => Types::DATETIME_MUTABLE, |
| 816 | + 'decimal' => Types::DECIMAL, |
| 817 | + 'double' => Types::FLOAT, |
| 818 | + 'enum' => Types::ENUM, |
| 819 | + 'float' => Types::SMALLFLOAT, |
| 820 | + 'geometry' => Types::GEOMETRY, |
| 821 | + 'geometrycollection' => Types::GEOMETRY, |
| 822 | + 'int' => Types::INTEGER, |
| 823 | + 'integer' => Types::INTEGER, |
| 824 | + 'json' => Types::JSON, |
| 825 | + 'linestring' => Types::GEOMETRY, |
| 826 | + 'longblob' => Types::BLOB, |
| 827 | + 'longtext' => Types::TEXT, |
| 828 | + 'mediumblob' => Types::BLOB, |
| 829 | + 'mediumint' => Types::INTEGER, |
| 830 | + 'mediumtext' => Types::TEXT, |
| 831 | + 'multilinestring' => Types::GEOMETRY, |
| 832 | + 'multipoint' => Types::GEOMETRY, |
| 833 | + 'multipolygon' => Types::GEOMETRY, |
| 834 | + 'numeric' => Types::DECIMAL, |
| 835 | + 'point' => Types::GEOMETRY, |
| 836 | + 'polygon' => Types::GEOMETRY, |
| 837 | + 'real' => Types::FLOAT, |
| 838 | + 'set' => Types::SIMPLE_ARRAY, |
| 839 | + 'smallint' => Types::SMALLINT, |
| 840 | + 'string' => Types::STRING, |
| 841 | + 'text' => Types::TEXT, |
| 842 | + 'time' => Types::TIME_MUTABLE, |
| 843 | + 'timestamp' => Types::DATETIME_MUTABLE, |
| 844 | + 'tinyblob' => Types::BLOB, |
| 845 | + 'tinyint' => Types::BOOLEAN, |
| 846 | + 'tinytext' => Types::TEXT, |
| 847 | + 'varbinary' => Types::BINARY, |
| 848 | + 'varchar' => Types::STRING, |
| 849 | + 'year' => Types::DATE_MUTABLE, |
831 | 850 | ]; |
832 | 851 | } |
833 | 852 |
|
|
0 commit comments