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 }