ORM leftJoin - results not in the ocrrect data type

I’m trying to do a manual leftJoin but the joined data that gets returned is all being output as “strings” instead of the appropriate datatype.(i.e (int) or (float) as you would expect.

The primary model is output as you’d expect - it’s only the joined data that is not the correct data type.

I read in the manual you can specify the datatype of the conditions; but there doesn’t seem to be any mention of why this be happening.

    $query = $this->Projects->find();
    $data = $query->select([
    ->leftJoin('Incomes', ['Projects.id = Incomes.project_id'])
    ->group(['Incomes.period_start', 'Incomes.income_type', 'project_id'])
    ->where(['Projects.client_id' => $id, 'Incomes.active' => true])
    ->order(['Incomes.period_start ASC']);

    $incomes = $data->all();
    $this->viewBuilder()->setOption('serialize', 'incomes');

And I end up with:

    "id": 3,
    "client_id": 2,
    "probability": "0.50",
    "value": 4000,
    "Incomes": {
        "period_start": "2020-05-01",
        "period_end": "2020-05-31",
        "income_type": "4",
        "probability": "0.50",

in this case it’s just “income_type” being represented as a string instead of an integer but it’s breaking my JSON. income_type is an integer in the database.

any ideas?

" When creating joins by hand and using array based conditions, you need to provide the datatypes for each column in the join conditions. By providing datatypes for the join conditions, the ORM can correctly convert data types into SQL. In addition to join() you can use rightJoin() , leftJoin() and innerJoin() to create joins:"