coldbox-modules / quick

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

Result of {asQuery, retrieveQuery} cannot be used as receiver of `.update(...)` (regression in 6.2.0 -> 6.2.1) #228

Open davidAtInleague opened 1 year ago

davidAtInleague commented 1 year ago

quick v6.2.1

This seems to occur using either retrieveQuery() or asQuery().

getInstance( "X" )
  .whereValue( 1 )
  .asQuery()
  .update( { 'v' : now().add( 'ww', 1 ) } );

6.2.0 is OK 6.2.1 throws:

lucee.runtime.exp.CasterException: Can't cast Object type [DateTime] to a value of type [Struct]
  at  lucee.runtime.op.Caster.toStruct(Caster.java:2737)
  at  lucee.runtime.op.Caster.toStruct(Caster.java:2716)
  at  modules.quick.models.quickqb_cfc$cf$d.udfCall2(/modules/quick/models/QuickQB.cfc:308)
  at  modules.quick.models.quickqb_cfc$cf$d.udfCall(/modules/quick/models/QuickQB.cfc)
  at  lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
  at  lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
  at  lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213)
  at  lucee.runtime.ComponentImpl._call(ComponentImpl.java:697)
  at  lucee.runtime.ComponentImpl._call(ComponentImpl.java:584)
  at  lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1950)
  at  lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:900)
  at  lucee.runtime.functions.dynamicEvaluation.Invoke.call(Invoke.java:49)
  at  models.quickbuilder_cfc$cf$c.udfCall5(/quick/models/QuickBuilder.cfc:656)
  at  models.quickbuilder_cfc$cf$c.udfCall(/quick/models/QuickBuilder.cfc)
  at  lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112)
  at  lucee.runtime.type.UDFImpl._call(UDFImpl.java:350)
  at  lucee.runtime.type.UDFImpl.call(UDFImpl.java:223)
  at  lucee.runtime.ComponentImpl._call(ComponentImpl.java:696)
  at  lucee.runtime.ComponentImpl.onMissingMethod(ComponentImpl.java:623)
  at  lucee.runtime.ComponentImpl._call(ComponentImpl.java:586)
  at  lucee.runtime.ComponentImpl.call(ComponentImpl.java:1931)
  at  lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787)
  at  lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1775)
  at  views.main.login_cfm$cf$e.call(/views/main/login.cfm:7)
  at  lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1056)
  at  lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:948)
  at  lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:929)
  at  system.web.rendererencapsulator_cfm$cf.call(/coldbox/system/web/RendererEncapsulator.cfm:54)
  at  lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1056)
  at  lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:948)
  at  lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:940)
  at  lucee.runtime.tag.CFTag.doInclude(CFTag.java:319)
  at  lucee.runtime.tag.CFTag.cfmlStartTag(CFTag.java:245)
  at  lucee.runtime.tag.CFTag.doStartTag(CFTag.java:179)
  at  system.web.renderer_cfc$cf.udfCall1(/coldbox/system/web/Renderer.cfc:469)
  at  system.web.renderer_cfc$cf.udfCall(/coldbox/system/web/Renderer.cfc)
  ...add'l frames elided
elpete commented 3 months ago

You shouldn't need the asQuery or retrieveQuery calls here. Instead use the QuickBuilder#updateAll method.