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

Cleanup #713

Merged
merged 8 commits into from
Apr 29, 2024
Merged

Cleanup #713

merged 8 commits into from
Apr 29, 2024

Conversation

markstory
Copy link
Member

Clean up several TODOs I had left behind while porting code in from phinx. I tried to leave useful commit logs for each of the changes.

Part of #647

Internal simple task objects feels like a more maintainable pattern than
traits do.
There is no suitable class in CakePHP. The database layer uses
`QueryExpression` to add raw SQL to specific query clauses, and thus has
no way to represent a literal value without providing a broad type.
It was not implemented before via migrations and doesn't need to exist anymore.
We only ever operate on a single path in the new flow. The console
arguments drive the migration configuration much more in the built-in
implementation. The parameters have good defaults and can be customized,
but there is no way to have more than one path presently.
@markstory markstory merged commit 873025c into no-phinx Apr 29, 2024
9 checks passed
@markstory markstory deleted the cleanup branch April 29, 2024 03:22

if (is_string($this->values['paths']['seeds'])) {
$this->values['paths']['seeds'] = [$this->values['paths']['seeds']];
if (is_array($this->values['paths']['seeds']) && isset($this->values['paths']['seeds'][0])) {
Copy link
Member

Choose a reason for hiding this comment

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

What is the point of this being an array if it's hard-coded to index 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was trying to keep compatibility with all the tests that provide a list of paths.

@@ -71,7 +82,7 @@ protected function getTablesToBake(CollectionInterface $collection, array $optio

$config = (array)ConnectionManager::getConfig($this->connection);
$key = isset($config['schema']) ? 'schema' : 'database';
if ($config[$key] === $split[1]) {
if (isset($split[0]) && $config[$key] === $split[1]) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this check $split[1] not 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

These were mostly to appease phpstan/psalm that were complaining about unchecked index access within the if block. I can add more isset() checks for 1 as well.

@@ -186,7 +197,7 @@ protected function fetchTableName(string $className, ?string $pluginName = null)
$config = ConnectionManager::getConfig($this->connection);
if ($config) {
$key = isset($config['schema']) ? 'schema' : 'database';
if ($config[$key] === $splitted[1]) {
if (isset($splitted[0]) && $config[$key] === $splitted[1]) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

markstory added a commit that referenced this pull request Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants