{"record":{"id":"a431f9df50db80fb","repo":"Tencent/APIJSON","slug":"from-value-value","errorCode":null,"errorMessage":"子查询 {}/{}:{ from:value } 中 value 对应的主表对象 {}:{} 不存在！","messagePattern":"子查询 (.+?)/(.+?):(.+?) 中 value 对应的主表对象 (.+?):(.+?) 不存在！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java","lineNumber":452,"sourceCode":"\n\t\t\t\tString from = getString(subquery, apijson.JSONRequest.KEY_SUBQUERY_FROM);\n\t\t\t\tboolean isEmpty = StringUtil.isEmpty(from);\n\t\t\t\tM arrObj = isEmpty ? null : JSON.get(obj, from);\n\t\t\t\tif (isEmpty) {\n\t\t\t\t\tSet<Entry<String, Object>> set = obj.entrySet();\n\t\t\t\t\tfor (Entry<String, Object> e : set) {\n\t\t\t\t\t\tString k = e == null ? null : e.getKey();\n\t\t\t\t\t\tObject v = k == null ? null : e.getValue();\n\t\t\t\t\t\tif (v instanceof Map<?, ?> && JSONMap.isTableKey(k)) {\n\t\t\t\t\t\t\tfrom = k;\n\t\t\t\t\t\t\tarrObj = (M) v;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (arrObj == null) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"子查询 \" + path + \"/\"\n                            + key + \":{ from:value } 中 value 对应的主表对象 \" + from + \":{} 不存在！\");\n\t\t\t\t}\n\n\t\t\t\tSQLConfig<T, M, L> cfg = (SQLConfig) arrObj.get(AbstractParser.KEY_CONFIG);\n\t\t\t\tif (cfg == null) {\n\t\t\t\t\tthrow new NotExistException(TAG + \".onParse  cfg == null\");\n\t\t\t\t}\n\n\t\t\t\tSubquery s = new Subquery();\n\t\t\t\ts.setPath(path);\n\t\t\t\ts.setOriginKey(key);\n\t\t\t\ts.setOriginValue(subquery);\n\n\t\t\t\ts.setFrom(from);\n\t\t\t\ts.setRange(range);\n\t\t\t\ts.setKey(replaceKey);\n\t\t\t\ts.setConfig(cfg);\n","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java#L434-L470","documentation":"After structuring a 'key{}@' subquery, the parser resolves the main table object designated by 'from'. If 'from' is provided and the object JSON.get(obj, from) is null — or 'from' was omitted and no entry inside the subquery object is a Map with a table key — this IllegalArgumentException fires, reporting the unresolved 'from' value.","triggerScenarios":"\"id{}@\": { \"from\": \"Comment\", \"Post\": { ... } } (from names a table not present), or { \"from\": \"comment\", ... } (wrong case / alias mismatch), or an object whose entries are all non-table keys.","commonSituations":"Renaming a table in the subquery but not updating 'from'; case mismatch between 'from' and the actual table key; using an alias ('Comment c') as the from value; forgetting the table object entirely.","solutions":["Set 'from' to exactly the table key used inside the subquery object (case-sensitive, no alias).","Double-check spelling/case: \"from\": \"Comment\" must match the key \"Comment\": {...}.","If 'from' is omitted, ensure at least one entry in the subquery object is a table-keyed JSONObject."],"exampleFix":"// before\n\"id{}@\": { \"from\": \"Comment\", \"comment\": { \"@column\": \"userId\" } }\n// after\n\"id{}@\": { \"from\": \"Comment\", \"Comment\": { \"@column\": \"userId\" } }","handlingStrategy":"validation","validationCode":"String from = (String) subquery.get(\"from\");\nboolean found = from == null || subquery.containsKey(from) && subquery.get(from) instanceof Map;\nif (!found) throw new IllegalArgumentException(\"from must name a table object inside the subquery\");","typeGuard":"function fromResolves(sub: Record<string, unknown>): boolean {\n  const f = sub.from;\n  return f == null || (typeof f === 'string' && sub[f] != null && typeof sub[f] === 'object' && !Array.isArray(sub[f]));\n}","tryCatchPattern":null,"preventionTips":["Keep 'from' identical (case-sensitive) to the table key inside the subquery.","Update 'from' whenever you rename the inner table key.","Don't use aliases in 'from'; use the plain table name."],"tags":["apijson","subquery","from","validation","request-syntax"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}