coldbox-modules / quick

A ColdBox ORM Engine
https://quick.ortusbooks.com
MIT License
23 stars 19 forks source link

empty belongsTo relation failing with full-null support in Lucee #154

Open wpdebruin opened 3 years ago

wpdebruin commented 3 years ago

When we have an empty belongsTo relation in a quick entity it fails with full null support. The belongsTo relation is calling the isBuilder function in qb. The isBuilder function in QueryUtils of qb is receiving:

which will never work with null values because it will fail on the structKeyExists. I tried adding a !IsNull( arguments.value ) check but still failing, in other places I guess.

wpdebruin commented 3 years ago

I finally tracked down the bug for a belongsTo relation with full null support. To get a correct result I had to add null checks for methods in both qb and quick. Methods which were failing where, in this order qb QueryUtils.isBuilder. I added a null check before everything else qb. QueryUtils.isNotExpression. Null check before everything else quick BaseEntity. isNullValue. The fun thing is that this method fails on a null value if value is null param arguments.value = invoke( this, "get" & arguments.key ); will fail. So adding an IsNull(value) before everything else will solve the problem.