DBAL-166: Table Encoding on generation table creation query #1324

Closed
doctrinebot opened this Issue Sep 14, 2011 · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user png-tech:

Can not set charset options for table creation.
Now I am fix thix problem in patch.
File: doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php

#!/usr/bin/php
<?php
/****

  • Doctrine DBAL Patch
  • fix table creation query encode
  • (c) _Nicolay */ system ('cp ./vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php ./vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php.Orig');

$data = filegetcontents('./vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php');
$data = str_replace("new Table(\$tableName);",
"new Table(\$tableName,array(),array(),array(),0,array('charset'=>'utf8','collate'=>'utf8generalci'));",
$data);
fileputcontents('./vendor/doctrine-dbal/lib/Doctrine/DBAL/Schema/Schema.php', $data);

@doctrinebot

Comment created by stfalcon:

Guys, it's real problem for me too! (:

My test suite (in symfony2 project) always creates tables with "latin1swedish_ci" collation. I want set "utf8_generalci". But I don't want do it's in mysql.ini.

I tried setting it in MysqlSessionInit **construct, but it's not solved my problem.

In MySqlPlatform I found next code (https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php#L420):

        if (isset($options['charset'])) {
            $optionStrings['charset'] = 'DEFAULT CHARACTER SET ' . $options['charset'];
            if (isset($options['collate'])) {
                $optionStrings['charset'] .= ' COLLATE ' . $options['collate'];
            }
        }

But any options don't set in this call
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/SchemaTool.php#L133

@doctrinebot

Comment created by @beberlei:

Implemented this as a new feature on Schema. Also defaulting to UTF-8 now.

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment