Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Plataforma MariaDB personalizada de Doctrine

CustomDbPlatform extendiendo MySqlPlatform basado en MariaDb1027Platform existente con el método getDefaultValueDeclarationSQL personalizado. No puedo extender MariaDbPlatform ya que es una clase final.

 class CustomDbPlatform extends MySqlPlatform { public function getJsonTypeDeclarationSQL(array $column): string { return 'LONGTEXT'; } protected function getReservedKeywordsClass(): string { return MariaDb102Keywords::class; } protected function initializeDoctrineTypeMappings(): void { parent::initializeDoctrineTypeMappings(); $this->doctrineTypeMapping['json'] = Types::JSON; } public function getDefaultValueDeclarationSQL($column): string { if (isset($column['default'], $column['type'])) { $default = $column['default']; $type = $column['type']; if ($type instanceof DateTimePrecisionType && stripos($default, $this->getCurrentTimestampSQL()) !== false) { if (isset($column['length']) && $column['length'] > 0 && $column['length'] < 255) { return ' DEFAULT ' . sprintf('%s(%d)', $this->getCurrentTimestampSQL(), $column['length']); } return ' DEFAULT ' . $this->getCurrentTimestampSQL(); } } return parent::getDefaultValueDeclarationSQL($column); } }

Desafortunadamente, durante la actualización del esquema, Doctrine obliga a actualizar básicamente todo el esquema con nuevas definiciones de columnas de tabla. Este problema lo causa MySqlSchemaManager , que verifica específicamente MariaDb1027Platform .

 if ($this->_platform instanceof MariaDb1027Platform) { $columnDefault = $this->getMariaDb1027ColumnDefault($this->_platform, $tableColumn['default']); } else { $columnDefault = $tableColumn['default']; }

¿Cómo puedo hacer que Doctrine reconozca mi CustomDbPlatform como MariaDb1027Platform ? Hacer SchemaManager personalizado parece ser una exageración.

Utilizando

  • Symfony 4.4
  • doctrina 2
  • Maria DB 10.3
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si desea extender MariaDb1027Platform , la única forma es:

  1. copie el archivo de clase de plataforma de https://github.com/doctrine/dbal/blob/3.1.x/src/Platforms/MariaDb1027Platform.php ,
  2. el lugar está en tu proyecto
  3. eliminar el kw final
  4. cargue este archivo antes de que la clase se cargue automáticamente desde DBAL lib; puede usar la sección de files de carga automática del compositor

Además, he creado PR https://github.com/doctrine/dbal/pull/4909 para ver si los mantenedores quieren apoyar esto oficialmente.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!