'Laravel Eloquent Multiple Joins Type Conversion

When I do a query like this with multiple joins and retrieve a single column on the nested join, in that example h.mv ,it looses it's type information in laravel and gets treated as a string whereas the column in the mysql database is a DECIMAL.

Account::select('accounts.*', 'accounts.id', 'h.mv', 'h.mv_local')
            ->with('currency')
            ->join('sem', 'sem.entity_id', '=', 'accounts.id')
            ->join('s', 's.id', '=', 'sem.security_id')
            ->join('h', 'h.security_id', '=', 's.id') 
            ->join('st', 'st.id', '=', 's.type1_id')
            ->join('hA', 'hA.id', '=', 'h.entity_id')
            ->where('st.name', '!=', 'CA') //
            ->where('h.date', $this->T)
            ->whereIn('accounts.type', ['pa', 'f'])
            ->where('hA.type', '!=', 'subMandate')
            ->whereRaw('`hA`.`asset_id` = `accounts`.`asset_id`')
            ->when($this->mandate_ids, function ($query) {
                return $query->whereIn('accounts.id', $this->custodial_ids);
            })
            ->get();

Is that expected behaviour when dealing with multiple joins? I can find old articles stating that the pdo bridge will treat every column as a string and laravel is doing the type conversion so I'm wondering what the constraints are on type conversion or even if that is actually what's happening?

Any experts on eloquent or the pdo layer who could give me some advice would be greatly appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source