{"record":{"id":"8591360802edd50a","repo":"Tencent/APIJSON","slug":"alias-key-value-value","errorCode":null,"errorMessage":"字符串 {alias} 不合法！预编译模式下 {key}:value 中 value里面用 ; 分割的每一项 function(arg0,arg1,...):alias 中 alias 必须是1个单词！并且不要有多余的空格！","messagePattern":"字符串 (.+?) 不合法！预编译模式下 (.+?):value 中 value里面用 ; 分割的每一项 function\\(arg0,arg1,\\.\\.\\.\\):alias 中 alias 必须是1个单词！并且不要有多余的空格！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java","lineNumber":2587,"sourceCode":"\t\t\t\t}\n\n\t\t\t\tString s = expression.substring(start + 1, end);\n\t\t\t\tboolean distinct = s.startsWith(PREFIX_DISTINCT);\n\t\t\t\tif (distinct) {\n\t\t\t\t\ts = s.substring(PREFIX_DISTINCT.length());\n\t\t\t\t}\n\n\t\t\t\t// 解析函数内的参数\n\t\t\t\tString ckeys[] = parseArgsSplitWithComma(s, false, containRaw, allowAlias);\n\n\t\t\t\tString suffix = expression.substring(end + 1); //:contactCount\n\t\t\t\tString alias = null;\n\t\t\t\tif (allowAlias) {\n\t\t\t\t\tint index = suffix.lastIndexOf(\":\");\n\t\t\t\t\talias = index < 0 ? \"\" : suffix.substring(index + 1); //contactCount\n\t\t\t\t\tsuffix = index < 0 ? suffix : suffix.substring(0, index);\n\t\t\t\t\tif (alias.isEmpty() == false && StringUtil.isName(alias) == false) {\n\t\t\t\t\t\tthrow new IllegalArgumentException(\"字符串 \" + alias + \" 不合法！预编译模式下 \"\n\t\t\t\t\t\t\t\t+ key + \":value 中 value里面用 ; 分割的每一项\"\n\t\t\t\t\t\t\t\t+ \" function(arg0,arg1,...):alias 中 alias 必须是1个单词！并且不要有多余的空格！\");\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (suffix.isEmpty() == false && (suffix.contains(\"--\") || suffix.contains(\"/*\")\n\t\t\t\t\t\t|| PATTERN_RANGE.matcher(suffix).matches() == false)) {\n\t\t\t\t\tthrow new UnsupportedOperationException(\"字符串 \" + suffix + \" 不合法！预编译模式下 \" + key\n\t\t\t\t\t\t\t+ \":\\\"column?value;function(arg0,arg1,...)?value...\\\"\"\n\t\t\t\t\t\t\t+ \" 中 ?value 必须符合正则表达式 \" + PATTERN_RANGE + \" 且不包含连续减号 -- 或注释符 /* ！不允许多余的空格！\");\n\t\t\t\t}\n\n\t\t\t\tString origin = fun + \"(\" + (distinct ? PREFIX_DISTINCT : \"\") + StringUtil.get(ckeys) + \")\" + suffix;\n\t\t\t\texpression = origin + (StringUtil.isEmpty(alias, true) ? \"\" : gainAs() + quote + alias + quote);\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//是窗口函数   fun(arg0,agr1) OVER (agr0 agr1 ...)\n\t\t\t\tint keyIndex = containOver ? overIndex : againstIndex;","sourceCodeStart":2569,"sourceCodeEnd":2605,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java#L2569-L2605","documentation":"After a function call in an @column-style expression, the text after the last ')' is split at the last ':' into suffix and alias; when allowAlias is true (GET @column) and the alias is non-empty but fails StringUtil.isName, this IllegalArgumentException is thrown. Aliases must be exactly one identifier word with no spaces.","triggerScenarios":"\"@column\":\"concat(a,b):my name\" (space in alias), \"@column\":\"sum(id):total-amount\" (hyphen), or a suffix colon from a format string being mistaken for an alias separator in malformed variants of date_format expressions.","commonSituations":"Developer wants a human-readable alias with spaces or punctuation; format strings inside the suffix introduce extra ':' characters; spaces copied from SQL 'AS my alias'.","solutions":["Use a single-word alias: \"sum(id):totalAmount\".","Remove all spaces around the ':'.","Keep ':' out of the suffix; if a format string needs ':', put the whole expression in @raw.","Omit the alias entirely if you do not need one."],"exampleFix":"// before\n{\"User\":{\"@column\":\"sum(id):total count\"}}\n// after\n{\"User\":{\"@column\":\"sum(id):totalCount\"}}","handlingStrategy":"validation","validationCode":"const NAME=/^[A-Za-z][A-Za-z0-9_]*$/;\nconst tail=expr.slice(expr.lastIndexOf(')')+1);\nconst i=tail.lastIndexOf(':');\nif(i>=0&&tail.slice(i+1)&&!NAME.test(tail.slice(i+1)))throw new Error('alias must be one word');","typeGuard":"null","tryCatchPattern":"catch IllegalArgumentException; sanitize alias and retry","preventionTips":["Single-word aliases only","No ':' inside suffixes","Trim whitespace before sending"],"tags":["apijson","sql","input-validation","alias"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}