{"record":{"id":"cccca4ebb989eefc","repo":"beego/beego","slug":"unknown-field-column-name-s","errorCode":null,"errorMessage":"unknown field/column name `%s`","messagePattern":"unknown field/column name `(.+?)`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"client/orm/db.go","lineNumber":1909,"sourceCode":"\n\ttables := newDbTables(mi, d.ins)\n\n\tvar (\n\t\tcols  []string\n\t\tinfos []*models.FieldInfo\n\t)\n\n\thasExprs := len(exprs) > 0\n\n\tQ := d.ins.TableQuote()\n\n\tif hasExprs {\n\t\tcols = make([]string, 0, len(exprs))\n\t\tinfos = make([]*models.FieldInfo, 0, len(exprs))\n\t\tfor _, ex := range exprs {\n\t\t\tindex, name, fi, suc := tables.parseExprs(mi, strings.Split(ex, ExprSep))\n\t\t\tif !suc {\n\t\t\t\tpanic(fmt.Errorf(\"unknown field/column name `%s`\", ex))\n\t\t\t}\n\t\t\tcols = append(cols, fmt.Sprintf(\"%s.%s%s%s %s%s%s\", index, Q, fi.Column, Q, Q, name, Q))\n\t\t\tinfos = append(infos, fi)\n\t\t}\n\t} else {\n\t\tcols = make([]string, 0, len(mi.Fields.DBcols))\n\t\tinfos = make([]*models.FieldInfo, 0, len(exprs))\n\t\tfor _, fi := range mi.Fields.FieldsDB {\n\t\t\tcols = append(cols, fmt.Sprintf(\"T0.%s%s%s %s%s%s\", Q, fi.Column, Q, Q, fi.Name, Q))\n\t\t\tinfos = append(infos, fi)\n\t\t}\n\t}\n\n\tquery, args := d.readValuesSQL(tables, cols, qs, mi, cond, tz)\n\n\trs, err := q.QueryContext(ctx, query, args...)\n\tif err != nil {\n\t\treturn 0, err","sourceCodeStart":1891,"sourceCodeEnd":1927,"githubUrl":"https://github.com/beego/beego/blob/939cfde380bb9f15844ad633b84f037f7da21584/client/orm/db.go#L1891-L1927","documentation":"ReadValues panics while resolving the requested output columns when an expression in Values/ValuesList/ValuesFlat cannot be resolved by dbTables.parseExprs (db.go:1907). Expressions are matched against the model's fields (Go field name or mapped column via Fields.GetByAny) and walked across relations with the '__' separator; anything unresolvable aborts query building before SQL is issued.","triggerScenarios":"qs.Values(&maps, \"Profiel__Name\") with a typo in the relation name; referencing a field of another model without going through a declared relation field; wrong hop order like \"Name__Profile\"; using a name that is neither the Go field name nor its orm column tag.","commonSituations":"Renaming struct fields without grepping query strings; mixing snake_case DB names with CamelCase Go names; copy-pasting expressions from another model's queries; deep relation paths through reverse/m2m fields that parseExprs does not support.","solutions":["Use the exact Go field name (case-sensitive) or the mapped column name, joining relation hops with __ (e.g. \"Profile__City__Name\")","Check the struct of the queried model and each hop; every intermediate segment must be a declared relation field","If the target is only a physical column with no mapped field, fall back to o.Raw(\"SELECT ...\").Values(&maps)","Enable orm.Debug during development to see where resolution stopped"],"exampleFix":"// before\nvar maps []orm.Params\nqs.Values(&maps, \"Profiel__Name\", \"Name\") // panic: unknown field/column name `Profiel__Name`\n\n// after\nvar maps []orm.Params\nqs.Values(&maps, \"Profile__Name\", \"Name\")","handlingStrategy":"validation","validationCode":"func knownFirstHop(t reflect.Type, expr string) bool {\n\tfirst := strings.Split(expr, \"__\")[0]\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tf := t.Field(i)\n\t\tif f.Name == first || f.Tag.Get(\"column\") == first {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\nif !knownFirstHop(reflect.TypeOf(User{}), exprs[0]) { /* reject before querying */ }","typeGuard":null,"tryCatchPattern":"err := func() (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"bad values expr: %v\", r)\n\t\t}\n\t}()\n\t_, err = qs.Values(&maps, exprs...)\n\treturn\n}()","preventionTips":["Centralize column expressions as constants next to the model","Use exact Go field names; do not guess physical column names","Run with orm.Debug=true while developing query expressions"],"tags":["orm","panic","query-building","field-not-found","values"],"backgroundTag":null,"analyzedSha":"939cfde380bb9f15844ad633b84f037f7da21584","analyzedAt":"2026-08-15T17:22:06.535Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}