This is interesting.
It is evident that when the class is compiled IRIS parse the <PropertyName>Computation() method(s) to find out what properties are actually used/referenced/passed to the cols.getfield() method(s), then it use this information to set the "fields" multidimensional property of %Library.PropertyHelper class before calling the <PropertyName>Computation() method.
This way only the used properties are set in the "fields" multidimensional property of %Library.PropertyHelper class.
This optimization improves performance in case of a class with many properties, possibly "complex" properties (calculated, references etc.) and I believe this is why has been implemented.
The "parser" is...simple, very simple.
To prove this assumption I wrote a little sample:
Class Community.Computation Extends %Persistent
{
Property FirstName As %String;
Property LastName As %String;
Property FullName As %String [ SqlComputed ];
ClassMethod FullNameComputation(cols As %Library.PropertyHelper) As %String
{
; cols.getfield("FirstName")
; cols.getfield("LastName")
return ..FullNameComputationSub(cols,"FirstName","LastName")
}
ClassMethod FullNameComputationSub(cols As %Library.PropertyHelper, p1 As %String, p2 As %String) As %String
{
return cols.getfield(p1)_" "_cols.getfield(p2)
}
/// do ##class(Community.Computation).test()
ClassMethod test()
{
set obj=..%New()
set obj.FirstName="Enrico"
set obj.LastName="Parisi"
write obj.FullName,!
}
}
If I run test() I get:
do ##class(Community.Computation).test()
Enrico ParisiIf I remove the commented line "; cols.getfield("FirstName")" and run test() again:
do ##class(Community.Computation).test()
ParisiIf you look at your error:
"set cols.fields("ropert")={ropert}'"
That's the parser that found "cols.getfield(property)" and assuming a string was passed removed the first and last characters (assuming were double quotes), so it got "ropert".
Bottom line, cols.fields() can only be used passing a string constant with a property name.
- Log in to post comments