Skip to content

Setting default collation in XML schema #573

Closed
drodil opened this Issue Mar 10, 2014 · 10 comments

5 participants

@drodil
drodil commented Mar 10, 2014

It would be awesome to set up the database collation (MySQL) in the schema XML database tag instead for each table separately. I have about 50 datatables in schema.xml and now I have to add the following lines for every table definition to get the collation to use UTF-8:

<table name="tmp">
    <vendor type="mysql">
        <parameter name="Collate" value="utf8_unicode_ci"/>
        <parameter name="Charset" value="utf8"/>
    </vendor>
</table>

It would be very nice to be able to set the database default collation and charset in database tag for example:

<database defaultVendor="mysql" defaultCollate="utf8_unicode_ci" defaultCharset="utf8">
@drodil
drodil commented Mar 10, 2014

Perhaps works for Charset but how about Collation? There are many different UTF-8 character sets in MySQL (http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html) so if it does work what of those it will use? Need to test that out if it works correctly.

@marcj
Propel member
marcj commented Mar 10, 2014

Nah, that runtime configuration is only the charset for the current connection. Your vendor stuff is something different. I give a +1 for this (trivial) change, so we can define vendor stuff directly under <database>.

@mpscholten
Propel member

I had the same issue in Propel1 so I would love to get this fixed here. I suggest keeping it simple and just allow the vendor-element to be defined on the database-level instead of adding new attributes. Like this

<database>
    <table> ... </table>

    <!-- global vendor -->
    <vendor>
         <parameter name="Charset" value="utf8" />
    </vendor>
</database>
@marcj
Propel member
marcj commented Apr 11, 2014

Yes, feel free to send pull requests. :+1:

@mpscholten
Propel member

To my surprise it seems that this is already supported by propel. Look here https://github.com/propelorm/Propel2/blob/master/src/Propel/Generator/Builder/Util/SchemaReader.php#L213 And later in the MysqlPlatform the database vendor info's get merged with the table vendor infos (https://github.com/propelorm/Propel2/blob/master/src/Propel/Generator/Platform/MysqlPlatform.php#L273)

@mpscholten
Propel member

Maybe we should add some documentation regarding this default vendor element?

@marcj
Propel member
marcj commented Apr 16, 2014
@mpscholten mpscholten added a commit to mpscholten/propelorm.github.com that referenced this issue Apr 23, 2014
@mpscholten mpscholten Added section about global vendor element in the schema reference
This should fix missing documentation for propelorm/Propel2#573
49a3715
@mpscholten mpscholten added a commit to mpscholten/propelorm.github.com that referenced this issue Apr 23, 2014
@mpscholten mpscholten Added section about global vendor element in the schema reference
This should fix missing documentation for propelorm/Propel2#573

Fixed line length

Added missing new line
fdfc8b9
@mpscholten
Propel member

@drodil your issue should be solved now. Checkout the documentation to set the default collation.

@drodil
drodil commented Apr 26, 2014

@mpscholten great, thanks!

@marcj marcj closed this Apr 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.