Skip to content

fix: use exist column in authorized table cleanup - #953

Closed
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/3752d53c1d63
Closed

add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/3752d53c1d63

Conversation

@add-uos

@add-uos add-uos commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

fix: use exist column in authorized table cleanup

  1. Root cause: clearEnableFromAuthorizedTable executed DELETE FROM
    authorized WHERE enable='true' but the table only has an exist
    boolean column, causing SQLite "no such column: enable" error
    and silently failing to clear authorized entries
  2. Fix: change WHERE clause to use exist column with numeric value
    1, matching the table schema and insertDataToAuthorizedTable
  3. Impact: clearEnableFromAuthorizedTable now correctly deletes rows
    where exist=1, no effect on other query paths

Influence:

  1. Verify authorized entries with exist=1 are deleted after calling
    clearEnableFromAuthorizedTable
  2. Verify entries with exist=0 are preserved after the call
  3. Confirm no SQLite error is logged during the operation

fix: 修复授权表清理时列名引用错误

  1. 根因:clearEnableFromAuthorizedTable执行DELETE FROM authorized
    WHERE enable='true',但表仅有exist布尔列,SQLite报"no such
    column: enable"导致函数静默失败,授权记录无法被清理
  2. 方案:将WHERE子句改为使用exist列并传数值1,与表结构和
    insertDataToAuthorizedTable写入逻辑一致
  3. 影响:clearEnableFromAuthorizedTable现在正确删除exist=1的行,
    不影响其他查询路径

Influence:

  1. 验证调用clearEnableFromAuthorizedTable后exist=1的记录被删除
  2. 验证exist=0的记录在调用后被保留
  3. 确认操作期间无SQLite错误日志输出

PMS: BUG-UT-DEF-001

Summary by Sourcery

Bug Fixes:

  • Correct authorized-table cleanup to delete entries marked as existing, preventing the previous invalid-column SQLite failure.

1. Root cause: clearEnableFromAuthorizedTable executed DELETE FROM
   authorized WHERE enable='true' but the table only has an exist
   boolean column, causing SQLite "no such column: enable" error
   and silently failing to clear authorized entries
2. Fix: change WHERE clause to use exist column with numeric value
   1, matching the table schema and insertDataToAuthorizedTable
3. Impact: clearEnableFromAuthorizedTable now correctly deletes rows
   where exist=1, no effect on other query paths

Influence:
1. Verify authorized entries with exist=1 are deleted after calling
   clearEnableFromAuthorizedTable
2. Verify entries with exist=0 are preserved after the call
3. Confirm no SQLite error is logged during the operation

fix: 修复授权表清理时列名引用错误

1. 根因:clearEnableFromAuthorizedTable执行DELETE FROM authorized
   WHERE enable='true',但表仅有exist布尔列,SQLite报"no such
   column: enable"导致函数静默失败,授权记录无法被清理
2. 方案:将WHERE子句改为使用exist列并传数值1,与表结构和
   insertDataToAuthorizedTable写入逻辑一致
3. 影响:clearEnableFromAuthorizedTable现在正确删除exist=1的行,
   不影响其他查询路径

Influence:
1. 验证调用clearEnableFromAuthorizedTable后exist=1的记录被删除
2. 验证exist=0的记录在调用后被保留
3. 确认操作期间无SQLite错误日志输出

PMS: BUG-UT-DEF-001
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 10 hours and 39 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates clearEnableFromAuthorizedTable to delete authorized records where the schema-backed exist flag is 1, fixing the SQLite column error while preserving records with exist=0 and leaving other query paths unchanged.

Sequence diagram for authorized table cleanup

sequenceDiagram
    participant Caller
    participant EnableSqlManager
    participant SQLite

    Caller->>EnableSqlManager: clearEnableFromAuthorizedTable()
    EnableSqlManager->>SQLite: DELETE FROM authorized WHERE exist=1
    SQLite-->>EnableSqlManager: Delete rows with exist=1
    Note over SQLite: Rows with exist=0 are preserved
Loading

File-Level Changes

Change Details Files
Correct the cleanup predicate to match the authorized table schema.
  • Replace the nonexistent enable column predicate with exist=1.
  • Retain execution error logging while allowing rows marked as existing to be deleted.
deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enablesqlmanager.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 clearEnableFromAuthorizedTable 函数中 SQL 查询条件使用错误列名和数据类型的问题, 将 WHERE 条件从 enable='true' 改为 exist=1。改动范围极小(单行变更),语法正确,逻辑清晰, 无安全漏洞(SQL 使用常量表名和硬编码整数构建,无用户输入),代码质量良好,性能无影响。 启发式扫描与 OCR 审查均未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 当前代码已正确,无需修改。 // clearEnableFromAuthorizedTable() 函数使用 exist=1 条件清理授权表, // SQL 参数均为常量和硬编码值,安全且正确。 void EnableSqlManager::clearEnableFromAuthorizedTable() {
    QString sql = QString("DELETE FROM %1 WHERE exist=%2;").arg(DB_TABLE_AUTHORIZED).arg(1);
    if (!m_sqlQuery.exec(sql)) {
        qCInfo(appLog) << m_sqlQuery.lastError();
    }
}

本报告由 AI 代码审查工具自动生成

@deepin-bot

deepin-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.75
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #956

@add-uos add-uos closed this Oct 30, 2026
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.

2 participants