Setting default collation in XML schema #573

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

Comments

Projects
None yet
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

This comment has been minimized.

Show comment
Hide comment
@drodil

drodil 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.

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

This comment has been minimized.

Show comment
Hide comment
@marcj

marcj Mar 10, 2014

Member

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>.

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

This comment has been minimized.

Show comment
Hide comment
@mpscholten

mpscholten Mar 10, 2014

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>
Member

mpscholten commented Mar 10, 2014

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

This comment has been minimized.

Show comment
Hide comment
@marcj

marcj Apr 11, 2014

Member

Yes, feel free to send pull requests. 👍

Member

marcj commented Apr 11, 2014

Yes, feel free to send pull requests. 👍

@mpscholten

This comment has been minimized.

Show comment
Hide comment
@mpscholten

mpscholten Apr 11, 2014

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)

Member

mpscholten commented Apr 11, 2014

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

This comment has been minimized.

Show comment
Hide comment
@mpscholten

mpscholten Apr 11, 2014

Member

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

Member

mpscholten commented Apr 11, 2014

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

@marcj

This comment has been minimized.

Show comment
Hide comment
Member

marcj commented Apr 16, 2014

mpscholten added a commit to mpscholten/propelorm.github.com that referenced this issue Apr 23, 2014

mpscholten added a commit to mpscholten/propelorm.github.com that referenced this issue Apr 23, 2014

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
@mpscholten

This comment has been minimized.

Show comment
Hide comment
@mpscholten

mpscholten Apr 23, 2014

Member

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

Member

mpscholten commented Apr 23, 2014

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

@drodil

This comment has been minimized.

Show comment
Hide comment

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