ERROR: Badly formatted SQL query: Expected scalar, got array instead!