lundi 3 octobre 2016

Laravel 5.2.43 vs 5.2.45 (Eloquent Sum returns null instead of 0)?

Just wanted to understand the difference between the 2 mentioned versions, Laravel v.5.2.43 and v.5.2.45.

I have observed the following difference:

// 5.2.43
// Returns 0 in case if there nothing with name Coffee
Product::where('name','Coffee')->sum('weight');

// 5.2.45
// Returns NULL in case if there nothing with name Coffee
Product::where('name','Coffee')->sum('weight');

I have a reporting tool, and the entire operations are collapsing when the value returned in NULL instead of a 0 in previous version.

My query here is that, is it a feature or a bug? If feature, is there a better alternative for changing the behavior? Or I have to change my code to accept this feature?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire