update
This commit is contained in:
@ -103,3 +103,18 @@
|
||||
### 待办(未做)
|
||||
- **运行期烟测**:起 pgvector Docker 实连,验证 GORM 把 `vector(64)` 列读进 `sql.NullString`(pgx text 格式扫描)无报错。尚未跑。
|
||||
- 汉明阈值 10 可按真实样本微调。
|
||||
|
||||
## 修复 `cmd/dbtool dump` 的 42601 + Scan 报错 ✅(22:25–22:50)
|
||||
`go run main.go dump` 导出 `brand` 表时连报两错,已逐个修掉:
|
||||
|
||||
### 错 1:SQLSTATE 42601 `at or near ")")`
|
||||
- 根因:`colQuery` 里 `c.column_name = $1` 这行第 5 列 `(c.column_default LIKE 'nextval(%'))` 多了一个右括号(应为 `nextval(%'`);多余的 `)` 让整段变 `... = $1))` 语法错。
|
||||
- 修复:改为 `(c.column_default LIKE 'nextval(%')`(单右括号,与 pkQuery 风格一致;该 `)` 是外层比较表达式收尾)。
|
||||
- 验证手段:另写 `_diag2` 临时诊断确认 `nextval(%')`(单)可查、`nextval(%'))`(双)必 42601,定位到就是这行。
|
||||
|
||||
### 错 2:`Scan error on column index 4 ... couldn't convert <nil> into type bool`
|
||||
- 根因:同上第 5 列当 `column_default` 为 NULL 时 `NULL LIKE 'nextval(%'` 返回 NULL,`rows.Scan(&isIdent bool)` 无法接收 NULL → 报错(`brand` 表无 serial 列,default 全 NULL 触发)。
|
||||
- 修复:改为 `COALESCE(c.column_default LIKE 'nextval(%', false)`,把 NULL 收为 false。
|
||||
|
||||
### 验证
|
||||
`go run main.go dump` → `✓ 已导出 15 张表 -> db_dump.json`,无报错。已删除 `_diag2` 临时诊断目录。
|
||||
|
||||
Reference in New Issue
Block a user