Menu

#537 Suggestion: make chosing MySQL collation easier

Git
closed-wont-fix
nobody
None
5
2017-03-15
2017-03-11
Yoji
No

Since there are a lot of collations in MySQL, it's a real pain to pick the frequently used UTF-8 and UTF8 unicode ci collations, which are used frequently.

So I made a test, modified the source code to include the favorites at the very beginning of the list:

File drivers/mysql.inc.php, Line 556, function collarions()

    function collations() {
        $return = array();
        $favorites = array(
            'ascii_bin',
            'ascii_general_ci',
            'utf8_bin',
            'utf8_unicode_ci',
        );
        foreach (get_rows("SHOW COLLATION") as $row) {
            if (in_array($row["Collation"], $favorites)) {
                $return['#Favorites'][] = $row["Collation"];
            } elseif ($row["Default"]) {
                $return[$row["Charset"]][-1] = $row["Collation"];
            } else {
                $return[$row["Charset"]][] = $row["Collation"];
            }
        }
        ksort($return);
        foreach ($return as $key => $val) {
            asort($return[$key]);
        }
        return $return;
    }

$return['#Favorites'] may be renamed to $return['#Frequently used']

See the attached png.

1 Attachments

Discussion

  • Jakub Vrána

    Jakub Vrána - 2017-03-15
    • status: open --> closed-wont-fix
     
  • Jakub Vrána

    Jakub Vrána - 2017-03-15

    It's possible to search in the list by typing.

    Also, setting the collation for the server sets the default for the newly created databases, database for the tables and table for columns. So you don't really need to set the collation that often.

    I am not comfortable with this change as different people can have different favorites. If you want to pursue this idea, send a pull request solving this in a plugin, not in the main Adminer code. You'll probably need to add a new method to the Adminer class and call it from collations().

     
  • Yoji

    Yoji - 2017-03-15
    • The default collation isn't always used. Depending on case insensitie, ascii or utf8, etc.
    • Search by typing doesn't help. This is why I had the idea... Searching 'utf' brings the first 'utf' string but not the desired one. So scrolling in the quite long list is anoying, especially considering the fact that 99.9% of the collations will be never used by the DB designer!
    • I just named 'Favorites' which in reality isn't favorite, but most used. It can be named 'General'. In the reality, 99% of the users will use those collations that are moved at the top of the list. ... or it is armenian collation so popular? :-)

    In fact, the all current db standards recommend to use utf-8 or utf-16, (beside plain ascii) so I still think it's a good idea to bring to the front the generic/most used collations, instead of burrying them deep betwen all kind of language collations.

     
  • Jakub Vrána

    Jakub Vrána - 2017-03-15

    My point is that in most cases, you don't need to select anything and the default (from the server, database or table) is used.

     

Log in to post a comment.

MongoDB Logo MongoDB