Skip to content

Fix export excel bugs - #906

Merged
freeplant merged 5 commits into
masterfrom
fix-export-excel-bugs
Aug 21, 2026
Merged

freeplant merged 5 commits into
masterfrom
fix-export-excel-bugs

Conversation

@AlexCXC

@AlexCXC AlexCXC commented Aug 20, 2026

Copy link
Copy Markdown
Contributor
  • fix export only 1000 rows
  • query view rows via SQL query instead of dtable-db /rows API
  • add some SQL unittest

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: Request changes

Blocking:

  • 普通视图的 SQL 没有固定排除归档行;见行内评论。
  • 深层嵌套过滤器组没有递归归一化「当前用户」条件;见行内评论。

if len(rows_rsp['rows']) < limit:
filter_conditions['start'] = start
filter_conditions['limit'] = limit
sql = filter2sql(table_name, columns, filter_conditions, by_group=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Critical] SQL 未排除归档行

为什么重要:
设计要求普通视图只读取非归档存储,但这里生成的 SQL 仅包含视图过滤、排序和 LIMIT。归档行只要满足视图过滤就会被导出,导致普通视图导出包含不应出现的数据。

建议修复:在生成导出 SQL 时无条件追加非归档谓词(并正确合并已有 WHERE),或给 filter2sql 增加明确的 normal-view/archived 开关,并补充归档行回归用例。

for index, filter_item in enumerate(filters):
sub_filters = filter_item.get('filters')
if sub_filters:
filters[index]['filters'] = [normalize_filter(filter, username, id_in_org, current_user_department_ids, current_user_department_and_sub_ids) for filter in sub_filters]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Critical] 用户条件未递归归一化

为什么重要:
SQL 构造器会递归处理任意层级的 filters,但此处只归一化顶层及其直接子项。两层以上分组中的「包含我」「当前用户 ID」或当前用户部门条件会保留占位值,导出结果会按错误用户或部门筛选。

建议修复:让 pre_filter_to_filter_term 对每个带 filters 的节点递归调用自身,并增加至少三层嵌套、覆盖三类当前用户条件的断言。

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: Request changes

Blocking:

  • 普通视图 SQL 仍未固定排除归档行;已有行内评论仍适用于当前提交。

Resolved:

  • 当前用户条件已改为递归归一化,并新增三层嵌套回归断言;此前对应阻塞项已解决。

]),
"SELECT * FROM `Table1` WHERE (((`Colla` in ('c@x.com', 'me@x.com')))) LIMIT 0, 100",
)
# deeply nested filter group (3 levels) current_user_department must still be normalized

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Warning] 深层用户条件测试覆盖不足

为什么重要:递归修复后的三层嵌套断言只覆盖了“包含我”和“当前用户所在部门”。“是当前用户 ID”及“当前用户所在部门 / 含子部门”仍只在顶层验证,未来这两条分支在递归路径回归时无法被测试拦截。

建议修复:在这里补充三层嵌套的 is_current_user_IDcurrent_user_department_and_sub(以及列表取值形式如适用)SQL 断言,确认每种当前用户条件都会被递归归一化。

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: Request changes

Blocking:

  • 普通视图导出 SQL 仍未固定排除归档行;已有行内评论(dtable_events/dtable_io/utils.py:1546)仍适用于当前提交。
    Suggested fix: 在生成导出 SQL 时无条件合并 _archived 的非归档谓词,并补充“满足视图筛选的归档行不会导出”的回归用例。

Resolved:

  • 当前用户相关条件已递归归一化;最新提交已补齐三层嵌套下“是当前用户 ID”和“当前用户所在部门 / 含子部门”(含列表取值)的断言。

@freeplant
freeplant merged commit 6ba3d38 into master Aug 21, 2026
1 check passed
@freeplant
freeplant deleted the fix-export-excel-bugs branch August 21, 2026 05:43
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.

3 participants