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