propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 398 forks source link

Reversing ENUM field with UTF-8 values fails #896

Open kordianbruck opened 9 years ago

kordianbruck commented 9 years ago

Consider a MYSQL Enum field with following allowed values:

'Antarktika','Australien','Afrika','Nordamerika','Südamerika','Europa','Asien'

when running propel reverse on this it will fail with an exception:

PHP Warning:  DOMElement::setAttribute(): string is not in UTF-8 in /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Schema/Dumper/XmlDumper.php on line 356
PHP Stack trace:
PHP   1. {main}() /var/www/icnmdb/vendor/propel/propel/bin/propel:0
PHP   2. include() /var/www/icnmdb/vendor/propel/propel/bin/propel:4
PHP   3. Symfony\Component\Console\Application->run() /var/www/icnmdb/vendor/propel/propel/bin/propel.php:29
PHP   4. Symfony\Component\Console\Application->doRun() /var/www/icnmdb/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP   5. Symfony\Component\Console\Application->doRunCommand() /var/www/icnmdb/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP   6. Symfony\Component\Console\Command\Command->run() /var/www/icnmdb/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP   7. Propel\Generator\Command\DatabaseReverseCommand->execute() /var/www/icnmdb/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:253
PHP   8. Propel\Generator\Manager\ReverseManager->reverse() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Command/DatabaseReverseCommand.php:93
PHP   9. Propel\Generator\Schema\Dumper\XmlDumper->dump() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Manager/ReverseManager.php:161
PHP  10. Propel\Generator\Schema\Dumper\XmlDumper->appendDatabaseNode() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Schema/Dumper/XmlDumper.php:64
PHP  11. Propel\Generator\Schema\Dumper\XmlDumper->appendTableNode() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Schema/Dumper/XmlDumper.php:156
PHP  12. Propel\Generator\Schema\Dumper\XmlDumper->appendColumnNode() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Schema/Dumper/XmlDumper.php:278
PHP  13. DOMElement->setAttribute() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Schema/Dumper/XmlDumper.php:356
PHP Warning:  DOMDocument::saveXML(): output conversion failed due to conv error, bytes 0xFC 0x64 0x61 0x6D in /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Schema/Dumper/XmlDumper.php on line 66
PHP Stack trace:
PHP   1. {main}() /var/www/icnmdb/vendor/propel/propel/bin/propel:0
PHP   2. include() /var/www/icnmdb/vendor/propel/propel/bin/propel:4
PHP   3. Symfony\Component\Console\Application->run() /var/www/icnmdb/vendor/propel/propel/bin/propel.php:29
PHP   4. Symfony\Component\Console\Application->doRun() /var/www/icnmdb/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP   5. Symfony\Component\Console\Application->doRunCommand() /var/www/icnmdb/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP   6. Symfony\Component\Console\Command\Command->run() /var/www/icnmdb/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP   7. Propel\Generator\Command\DatabaseReverseCommand->execute() /var/www/icnmdb/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:253
PHP   8. Propel\Generator\Manager\ReverseManager->reverse() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Command/DatabaseReverseCommand.php:93
PHP   9. Propel\Generator\Schema\Dumper\XmlDumper->dump() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Manager/ReverseManager.php:161
PHP  10. DOMDocument->saveXML() /var/www/icnmdb/vendor/propel/propel/src/Propel/Generator/Schema/Dumper/XmlDumper.php:66
Schema reverse engineering finished.

The outputed xml is incomplete and stops right at the 'ü' sign.

lumpiluk commented 9 years ago

In case anyone's having similar problems, for me the solution was to append "charset=UTF8", resulting in the following command:

propel reverse 'mysql:host=localhost;dbname=backup_2015-08-10;user=root;password=;charset=UTF8'
rinkla3024 commented 3 years ago

May I ask what is the underlying datatype the enum is represented as in the base class? My reverse command succeeds, but reading of data always returns null.