Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting default collation in XML schema #573

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

Setting default collation in XML schema #573

drodil opened this issue Mar 10, 2014 · 10 comments
Labels

Comments

@drodil
Copy link

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">
@stood
Copy link

stood commented Mar 10, 2014

@drodil
Copy link
Author

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

marcj commented Apr 11, 2014

Yes, feel free to send pull requests. 👍

@mpscholten
Copy link
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
Copy link
Member

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

@marcj
Copy link
Member

marcj commented Apr 16, 2014

@mpscholten yes.

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
This should fix missing documentation for propelorm/Propel2#573

Fixed line length

Added missing new line
@mpscholten
Copy link
Member

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

@drodil
Copy link
Author

drodil commented Apr 26, 2014

@mpscholten great, thanks!

@marcj marcj closed this as completed Apr 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants