Skip to content

[Cache][Lock] PdoAdapter/PdoStore minor cleanup #52667

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

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented Nov 21, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

Follow up to #52459.

Basically some code cleanup such as using match instead of switch + a minor sync between the PdoAdapter and PdoStore.

I've targeted 6.4 since this is just a minor code cleanup, but I can switch to 7.1 if needed.

@nicolas-grekas
Copy link
Member

can you please rebase?

@HypeMC HypeMC force-pushed the sync-pdo-adapter-and-store branch from 5fae508 to f5baad5 Compare November 21, 2023 09:31
@HypeMC
Copy link
Contributor Author

HypeMC commented Nov 21, 2023

can you please rebase?

@nicolas-grekas Done

Comment on lines 379 to 386
return match (true) {
'pgsql' === $driver && '42P01' === $code,
'sqlite' === $driver && str_contains($exception->getMessage(), 'no such table:'),
'oci' === $driver && 942 === $code,
'sqlsrv' === $driver && 208 === $code,
'mysql' === $driver && 1146 === $code => true,
default => false,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return match (true) {
'pgsql' === $driver && '42P01' === $code,
'sqlite' === $driver && str_contains($exception->getMessage(), 'no such table:'),
'oci' === $driver && 942 === $code,
'sqlsrv' === $driver && 208 === $code,
'mysql' === $driver && 1146 === $code => true,
default => false,
};
return match ($driver) {
'pgsql' => '42P01' === $code,
'sqlite' => str_contains($exception->getMessage(), 'no such table:'),
'oci' => 942 === $code,
'sqlsrv' => 208 === $code,
'mysql' => 1146 === $code,
default => false,
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, looks much better this way, done.

Comment on lines 246 to 253
return match (true) {
'pgsql' === $driver && '42P01' === $code,
'sqlite' === $driver && str_contains($exception->getMessage(), 'no such table:'),
'oci' === $driver && 942 === $code,
'sqlsrv' === $driver && 208 === $code,
'mysql' === $driver && 1146 === $code => true,
default => false,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    return match ($driver) {
        'pgsql' => '42P01' === $code,
        'sqlite' => str_contains($exception->getMessage(), 'no such table:'),
        'oci' => 942 === $code,
        'sqlsrv' => 208 === $code,
        'mysql' => 1146 === $code,
        default => false,
    };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@HypeMC HypeMC force-pushed the sync-pdo-adapter-and-store branch from f5baad5 to 45e17d5 Compare November 21, 2023 09:41
@nicolas-grekas
Copy link
Member

Thank you @HypeMC.

@nicolas-grekas nicolas-grekas merged commit 605297c into symfony:6.4 Nov 21, 2023
@HypeMC HypeMC deleted the sync-pdo-adapter-and-store branch November 21, 2023 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants