{"record":{"id":"bdb9014513f44109","repo":"greenrobot/greenDAO","slug":"illegal-value-found-array-but-simple-object-requ","errorCode":null,"errorMessage":"Illegal value: found array, but simple object required","messagePattern":"Illegal value: found array, but simple object required","errorType":"exception","errorClass":"DaoException","httpStatus":null,"severity":"error","filePath":"DaoCore/src/main/java/org/greenrobot/greendao/query/WhereCondition.java","lineNumber":75,"sourceCode":"        }\n\n        @Override\n        public void appendValuesTo(List<Object> valuesTarget) {\n            if (hasSingleValue) {\n                valuesTarget.add(value);\n            } else if (values != null) {\n                for (Object value : values) {\n                    valuesTarget.add(value);\n                }\n            }\n        }\n    }\n\n    class PropertyCondition extends AbstractCondition {\n\n        private static Object checkValueForType(Property property, Object value) {\n            if (value != null && value.getClass().isArray()) {\n                throw new DaoException(\"Illegal value: found array, but simple object required\");\n            }\n            Class<?> type = property.type;\n            if (type == Date.class) {\n                if (value instanceof Date) {\n                    return ((Date) value).getTime();\n                } else if (value instanceof Long) {\n                    return value;\n                } else {\n                    throw new DaoException(\"Illegal date value: expected java.util.Date or Long for value \" + value);\n                }\n            } else if (property.type == boolean.class || property.type == Boolean.class) {\n                if (value instanceof Boolean) {\n                    return ((Boolean) value) ? 1 : 0;\n                } else if (value instanceof Number) {\n                    int intValue = ((Number) value).intValue();\n                    if (intValue != 0 && intValue != 1) {\n                        throw new DaoException(\"Illegal boolean value: numbers must be 0 or 1, but was \" + value);\n                    }","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/greenrobot/greenDAO/blob/0bbb338e17c4cf28aba5aae62d42f73f50186157/DaoCore/src/main/java/org/greenrobot/greendao/query/WhereCondition.java#L57-L93","documentation":"WhereCondition.PropertyCondition.checkValueForType() validates the value bound to a comparison condition. Only scalar (non-array) values are allowed; if the value is a Java array, a DaoException is thrown. For IN conditions use the dedicated in(...) variants, which accept arrays/lists.","triggerScenarios":"Calling where(Properties.Id.eq(idsArray)) or .notEq(arr) — any eq/lessThan/greaterThan-style condition given an array or a boxed array as the value.","commonSituations":"Developers intending an IN query pass an array to eq() instead of Properties.X.in(...), or Kotlin/Java interop converts a varargs call into an array argument.","solutions":["Use in()/notIn() for array/list values: where(Properties.Id.in(ids)).","Pass a single scalar to eq()/gt()/lt() conditions.","If a variable holds a single value that is an array due to varargs capture, extract the element first."],"exampleFix":"// before\nList<User> users = userDao.queryBuilder()\n  .where(UserDao.Properties.Id.eq(ids)).list(); // array value -> DaoException\n// after\nList<User> users = userDao.queryBuilder()\n  .where(UserDao.Properties.Id.in(ids)).list();","handlingStrategy":"validation","validationCode":"if (value != null && value.getClass().isArray()) {\n  // use Properties.X.in((Object[]) value) instead of eq\n}","typeGuard":"boolean isScalar(Object v) { return v == null || !v.getClass().isArray() && !(v instanceof java.util.Collection); }","tryCatchPattern":"try { cond = Properties.Id.eq(v); } catch (DaoException e) { cond = Properties.Id.in((Object[]) v); }","preventionTips":["Use in()/notIn() for any array or collection.","Keep eq/gt/lt values strictly scalar.","Watch Kotlin varargs and Java boxing that wrap values in arrays."],"tags":["greendao","where-condition","android","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"0bbb338e17c4cf28aba5aae62d42f73f50186157","analyzedAt":"2026-09-08T03:22:36.050Z","contentChangedAt":"2026-09-08T03:22:36.050Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}