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

fix: Forge::dropColumn() seems to always return false. #8931

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

ping-yee
Copy link
Contributor

@ping-yee ping-yee commented Jun 1, 2024

Description
Fixes #8849
I think return sql execute result directly is a simplest way to fix this issue.

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

system/Database/Forge.php Outdated Show resolved Hide resolved
@kenjis kenjis added bug Verified issues on the current code behavior or pull requests that will fix them database Issues or pull requests that affect the database layer labels Jun 1, 2024
writable/test_com.sitedb.web Outdated Show resolved Hide resolved
Comment on lines +174 to +177
throw new DatabaseException(
'Failed to drop column. Table: "' . $table
. '", Column: "' . $columns . '"'
);
Copy link
Member

Choose a reason for hiding this comment

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

dropColumn() may return false when $this->db->DBDebug is false.
So make this the same, please.

public function dropColumn(string $table, $columnNames)
{
$sql = $this->_alterTable('DROP', $this->db->DBPrefix . $table, $columnNames);
if ($sql === false) {
if ($this->db->DBDebug) {
throw new DatabaseException('This feature is not available for the database you are using.');
}
return false;
}
return $this->db->query($sql);
}

Copy link
Member

Choose a reason for hiding this comment

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

@ping-yee Can you complete this PR?
We are very close to the completion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kenjis Sorry for the stagnation, I haven’t had much energy to deal with things other than work a while ago.
I modify this right now.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, the rector removed the return false line, implying that if sqlExecuteResult is false, the method would still return false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them database Issues or pull requests that affect the database layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug(SQLite3): Forge::dropColumn() seems to always return false
2 participants