From f8e59e9850b227a6919a2fa565cc4b57a752ff6a Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sun, 5 Jul 2026 00:16:26 -0600 Subject: [PATCH] fix: address SQL feature code review findings - Normalize student SQL to end with exactly one semicolon before appending the trailing SELECT, so a missing trailing ; no longer produces a confusing parse error (sqlTable.ts) - Remove unused description field from SqlTablePreset and all presets (dead data, nothing in the UI reads it) - Clear output when the candidate table selection changes, so stale results from the previous table don't linger (SqlSection.vue) - Remove stray console.log(props.language) debug statement (CodeEditor.vue) Co-Authored-By: Claude Sonnet 5 --- src/components/CodeEditor.vue | 1 - src/composables/sqlTable.ts | 3 ++- src/data/sqlTables.ts | 4 ---- src/desktop/SqlSection.vue | 7 ++++++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/CodeEditor.vue b/src/components/CodeEditor.vue index c6e3de0..8e3a7ae 100644 --- a/src/components/CodeEditor.vue +++ b/src/components/CodeEditor.vue @@ -65,7 +65,6 @@ const langExtension = computed(() => { }) const enhanceAutoCompletion = computed(() => { - console.log(props.language) return autocompletion({ override: [enhanceCompletion(props.language), completeAnyWord], }) diff --git a/src/composables/sqlTable.ts b/src/composables/sqlTable.ts index 15534cc..aba882d 100644 --- a/src/composables/sqlTable.ts +++ b/src/composables/sqlTable.ts @@ -11,5 +11,6 @@ export function buildSqlScript(studentSql: string) { const table = sqlTables.find((item) => item.id === selectedTableId.value) ?? sqlTables[0] - return `${table.setupSql}\n\n${studentSql}\n\nSELECT * FROM ${table.tableName};` + const normalizedSql = studentSql.trim().replace(/;?\s*$/, ";") + return `${table.setupSql}\n\n${normalizedSql}\n\nSELECT * FROM ${table.tableName};` } diff --git a/src/data/sqlTables.ts b/src/data/sqlTables.ts index f47e290..8c657d1 100644 --- a/src/data/sqlTables.ts +++ b/src/data/sqlTables.ts @@ -1,7 +1,6 @@ export interface SqlTablePreset { id: string label: string - description: string tableName: string setupSql: string } @@ -63,21 +62,18 @@ export const sqlTables: SqlTablePreset[] = [ { id: "students", label: "学生成绩表", - description: "适合练习按分数筛选、批量更新、删除不及格记录", tableName: "students", setupSql: studentsSetupSql, }, { id: "employees", label: "员工工资表", - description: "适合练习按部门分组调薪、按入职日期筛选", tableName: "employees", setupSql: employeesSetupSql, }, { id: "products", label: "商品库存表", - description: "适合练习新增商品、调整库存、下架缺货商品", tableName: "products", setupSql: productsSetupSql, }, diff --git a/src/desktop/SqlSection.vue b/src/desktop/SqlSection.vue index 77593ff..2d66fa3 100644 --- a/src/desktop/SqlSection.vue +++ b/src/desktop/SqlSection.vue @@ -1,6 +1,7 @@