🐛 fix(mongodb/query-editor): 修复受限账号连接与不限行数

- MongoDB 指定数据库时保留连接校验并跳过全库枚举
- 允许查询最大行数为 0 并持久化不限设置
- 补充数据库枚举与不限行数持久化回归测试

Refs #741
Refs #752
This commit is contained in:
Syngnat
2026-07-29 17:19:15 +08:00
parent 61358b1a62
commit bd259e4e51
4 changed files with 145 additions and 7 deletions

View File

@@ -314,6 +314,23 @@ describe('store appearance persistence', () => {
expect(reloaded.useStore.getState().queryOptions.wordWrap).toBe(true);
});
it('persists zero as the unlimited SQL query row limit', async () => {
const { useStore } = await importStore();
useStore.getState().setQueryOptions({ maxRows: 0 });
expect(useStore.getState().queryOptions.maxRows).toBe(0);
const persisted = JSON.parse(storage.getItem('lite-db-storage') || '{}');
expect(persisted.state.queryOptions.maxRows).toBe(0);
vi.resetModules();
const reloaded = await importStore();
expect(reloaded.useStore.getState().queryOptions.maxRows).toBe(0);
reloaded.useStore.getState().setQueryOptions({ maxRows: -1 });
expect(reloaded.useStore.getState().queryOptions.maxRows).toBe(5000);
});
it('persists the table overview view mode across store reloads', async () => {
const { useStore } = await importStore();
expect(useStore.getState().queryOptions.tableOverviewViewMode).toBeUndefined();

View File

@@ -2794,7 +2794,7 @@ const sanitizeQueryOptions = (value: unknown): QueryOptions => {
const queryEditorEditorHeightRatio = sanitizeQueryEditorEditorHeightRatio(
raw.queryEditorEditorHeightRatio,
);
if (!Number.isFinite(maxRows) || maxRows <= 0) {
if (!Number.isFinite(maxRows) || maxRows < 0) {
return {
maxRows: 5000,
wordWrap,