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

mysql8 - getDatabaseSchemata returns DEFAULT_CHARACTER_SET_NAME default_character_set_name #106

Closed
decrypted opened this issue Feb 22, 2022 · 3 comments
Assignees
Labels

Comments

@decrypted
Copy link

hey,

MySqlSchemaAdapter has troubles with mysql8.0.

My original idea to config PDO::ATTR_CASE as lowerkey is not an option as phinx itself depends too heavily on it being natural.

Best idea so far is

public function getSchema($tableNames = null): array

to run

$result['database'] = array_change_key_case($this->getDatabaseSchemata($this->dbName),CASE_LOWER);

open for other ideas

The problem does not show up on a fresh schema.php generated from scratch as getTableMigrationNewDatabase $this->array->neq on both null is false.

Thx

@odan
Copy link
Owner

odan commented Feb 22, 2022

Hi!

Can you explain this issue a little more in detail?
What is the actual problem or the difference in MySQL 8 with the database name?
I think we cannot just change the database name for all users to lower-case.

@decrypted
Copy link
Author

` private function getDatabaseSchemata(string $dbName): array
{
$sql = 'SELECT
default_character_set_name,
default_collation_name
FROM information_schema.SCHEMATA
WHERE schema_name = %s;';
$sql = sprintf($sql, $this->quote($dbName));

    return $this->createQueryStatement($sql)->fetch();
}`

for MYSQL8 the default_character_set_name and the other things in the array (for getDatabaseSchemata) come back uppercase, the checks are lowercase

if ($this->array->neq($new, $old, ['database', 'default_character_set_name'])) {

so this is NULL for MYSQL8

@odan odan self-assigned this Feb 22, 2022
@odan odan added the bug label Feb 22, 2022
@odan
Copy link
Owner

odan commented Feb 22, 2022

Thanks for reporting this bug. This should now be fixed in the latest version. Please update and tell me if it works now.

@odan odan closed this as completed Feb 28, 2022
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

2 participants