{"record":{"id":"a69892cb65e4a0c3","repo":"Tencent/APIJSON","slug":"value-key","errorCode":null,"errorMessage":"{}:value 中key不合法！不支持 ! 以外的逻辑符 ！","messagePattern":"(.+?):value 中key不合法！不支持 ! 以外的逻辑符 ！","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java","lineNumber":4043,"sourceCode":"\t\tdefault:  // TODO MySQL JSON类型的字段对比 key='[]' 会无结果！ key LIKE '[1, 2, 3]'  //TODO MySQL , 后面有空格！\n\t\t\treturn gainEqualString(key, column, value, rawSQL);\n\t\t}\n\t}\n\n\n\tpublic String gainEqualString(String key, String column, Object value, String rawSQL) throws Exception {\n\t\tif (value != null && JSON.isBoolOrNumOrStr(value) == false && value instanceof Subquery == false) {\n\t\t\tthrow new IllegalArgumentException(key + \":value 中value不合法！非PUT请求只支持 [Boolean, Number, String] 内的类型 ！\");\n\t\t}\n\n\t\tboolean not = column.endsWith(\"!\"); // & | 没有任何意义，写法多了不好控制\n\t\tif (not) {\n\t\t\tcolumn = column.substring(0, column.length() - 1);\n\t\t}\n\n\t\tString rc = column.endsWith(\"[\") || column.endsWith(\"{\") ? column.substring(0, column.length() - 1) : column;\n\t\tif (StringUtil.isName(rc) == false) {\n\t\t\tthrow new IllegalArgumentException(key + \":value 中key不合法！不支持 ! 以外的逻辑符 ！\");\n\t\t}\n\n\t\tString logic = value == null && rawSQL == null ? (not ? SQL.IS_NOT : SQL.IS) : (not ? \" != \" : \" = \");\n\t\treturn gainKey(column) + logic + (value instanceof Subquery ? gainSubqueryString((Subquery<T, M, L>) value)\n\t\t\t\t: (rawSQL != null ? rawSQL : gainValue(key, column, value)));\n\t}\n\n\tpublic String gainCompareString(String key, String column, Object value, String type, String rawSQL) throws Exception {\n\t\tif (value != null && JSON.isBoolOrNumOrStr(value) == false && value instanceof Subquery == false) {\n\t\t\tthrow new IllegalArgumentException(key + \":value 中 value 不合法！比较运算 [>, <, >=, <=] 只支持 [Boolean, Number, String] 内的类型 ！\");\n\t\t}\n\n\t\tString rc = column.endsWith(\"[\") || column.endsWith(\"{\") ? column.substring(0, column.length() - 1) : column;\n\t\tif ( ! StringUtil.isName(rc)) {\n\t\t\tthrow new IllegalArgumentException(key + \":value 中 key 不合法！比较运算 [>, <, >=, <=] 不支持 [&, !, |] 中任何逻辑运算符 ！\");\n\t\t}\n\n\t\treturn gainKey(column) + \" \" + type + \" \" + (value instanceof Subquery ? gainSubqueryString((Subquery<T, M, L>) value)","sourceCodeStart":4025,"sourceCodeEnd":4061,"githubUrl":"https://github.com/Tencent/APIJSON/blob/5284052872898eddc449a58f629e5c8d588b8e22/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java#L4025-L4061","documentation":"Thrown by gainEqualString when, after stripping the optional '!' (NOT) suffix and the optional '[' / '{' length-function suffix, the remaining column string fails StringUtil.isName(). This means the key contains characters not legal for a column identifier (e.g. '&', '|', or punctuation), so the library refuses to embed it in SQL.","triggerScenarios":"A condition key like \"name&\", \"col|other\", \"a.b.c!\" or any key whose base part is not a valid identifier (letters, digits, '_', '$', and dot-separated parts per isName rules).","commonSituations":"Trying to express AND/OR logic by gluing operators onto the key (\"price&>10\" style), malformed dynamic keys built client-side, or keys containing SQL meta-characters.","solutions":["Use only valid column names in keys; strip stray operators.","Express AND/OR via @combine, not via symbols inside the key.","Express NOT with the trailing '!' suffix only: \"key!\": value; use length via \"key[\" and json_length via \"key{\"."],"exampleFix":"// before\n{\"User\": {\"name&\": \"az\"}}\n// after\n{\"User\": {\"name\": \"az\", \"@combine\": \"name & tag\"}}","handlingStrategy":"validation","validationCode":"function isName(s) { return /^[A-Za-z_$][\\w$]*(\\.[A-Za-z_$][\\w$]*)*$/.test(s); }\nfunction validEqKey(key) {\n  let k = key.endsWith('!') ? key.slice(0, -1) : key;\n  k = k.endsWith('[') || k.endsWith('{') ? k.slice(0, -1) : k;\n  return isName(k);\n}\nif (!validEqKey(condKey)) throw new Error('bad column key ' + condKey);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep condition keys to plain column names plus documented suffixes (!, [, {).","Express logic with @combine, never with symbols inside keys."],"tags":["apijson","column-name","identifier","validation"],"backgroundTag":null,"analyzedSha":"5284052872898eddc449a58f629e5c8d588b8e22","analyzedAt":"2026-08-14T15:15:29.577Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}