3f2626f621
build / build (push) Failing after 1m32s
按 schema 版本选 profile 并以 information_schema 能力探测放行,取代写死的 version==74;未知版本、脏库、缺表缺列、跨版本搬运一律拒绝并点名原因。 0.9.0 的索引名改从部署配置解析,wiki_log_entries 按 profile 变为可选, 归档部件集合随之一致。
51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package v071
|
|
|
|
import (
|
|
"knowledge-governance/internal/libraryprofile"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/jackc/pgx/v5/pgconn"
|
|
)
|
|
|
|
// schemaProbeRows 给"按 SQL 打桩"的既有夹具提供 information_schema 能力探测答案。
|
|
// 0.7.1 的假库一律按 profile 声明的表/列回答,这样能力探测在单测里也是真的被走了一遍,
|
|
// 而不是被桩悄悄放行。
|
|
type schemaProbeRows struct {
|
|
pairs [][2]string
|
|
index int
|
|
}
|
|
|
|
func legacySchemaProbeRows() *schemaProbeRows {
|
|
profile, err := libraryprofile.For(libraryprofile.LegacyVersion)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
rows := &schemaProbeRows{}
|
|
for _, table := range profile.RequiredTables {
|
|
for _, column := range profile.RequiredColumns[table] {
|
|
rows.pairs = append(rows.pairs, [2]string{table, column})
|
|
}
|
|
}
|
|
return rows
|
|
}
|
|
|
|
func (r *schemaProbeRows) Close() {}
|
|
func (r *schemaProbeRows) Err() error { return nil }
|
|
func (r *schemaProbeRows) CommandTag() pgconn.CommandTag { return pgconn.CommandTag{} }
|
|
func (r *schemaProbeRows) FieldDescriptions() []pgconn.FieldDescription { return nil }
|
|
func (r *schemaProbeRows) RawValues() [][]byte { return nil }
|
|
func (r *schemaProbeRows) Conn() *pgx.Conn { return nil }
|
|
func (r *schemaProbeRows) Next() bool {
|
|
if r.index >= len(r.pairs) {
|
|
return false
|
|
}
|
|
r.index++
|
|
return true
|
|
}
|
|
func (r *schemaProbeRows) Scan(dest ...any) error {
|
|
*dest[0].(*string) = r.pairs[r.index-1][0]
|
|
*dest[1].(*string) = r.pairs[r.index-1][1]
|
|
return nil
|
|
}
|
|
func (r *schemaProbeRows) Values() ([]any, error) { return nil, nil }
|