User bio
404 bio not found
Member since Jul 25, 2017
Posts:
Replies:
I think, Enrico was more aiming for the point that “concatenation is the gateway for SQL injection.”
An easy and simple (assuming standard storage strategy) way to get those informations (the slot numbers, where a property is stored) could be achieved with a simple classmethod
Class DC.PropInfo [ Abstract ]
{
/// Info about properties of a class:
/// - list of all properties stored in a list
/// - slot number for a given property
///
/// 1) add this class to your class definition
/// class some.class extends (%Persistent, DC.StorageInfo) or
/// class some.class extends (%SerialClass, DC.StorageInfo)
///
/// 2) then use it as follows
/// write ##class(some.class).PropInfo() --> list of property names
/// write ##class(some.class).PropInfo("Age") --> slot number for the Age property
///
/// write ##class(
ClassMethod PropInfo(name = "") As %String [ CodeMode = objectgenerator ]
{
set sto=%compiledclass.Storages, prp=0, list=""
if sto.Count()=1 {
set dat=sto.GetAt(1).Data
for i=1:1:dat.Count() if dat.GetAt(i).Structure="listnode" set prp=dat.GetAt(i) quit
if prp {
if %compiledclass.ClassType="serial" { set list="", i=1 } else { set list=$lb(""), i=2 }
for i=i:1:prp.Values.Count() set list=list_$lb(prp.Values.GetAt(i).Value)
}
do %code.WriteLine(" if name="""" quit """_$lts(list)_"""")
do %code.WriteLine(" quit $lf($lfs("""_$lts(list)_"""),name)")
}
if list="" write !,"*** No properties found! ***"
quit $$$OK
}
}
Two test classes
Class DC.TestPerson Extends (%Persistent, DC.PropInfo)
{
Property Name As %String;
Property Addr As DC.Address;
Property Salary As %Numeric;
Property Expertise As list Of %String;
}
Class DC.Address Extends (%SerialObject,DC.PropInfo)
{
Property Street As %String;
Property City As %String;
}
Now you can do things like:
write ##class(DC.TestPerson).PropInfo() --> ,Name,Addr,Salary,Expertise
write ##class(DC.TestPerson).PropInfo("Salary") --> 4
// you can use the slot number for direct data access:
write $list(^DC.TestPersonD(id),slotnumber) gives you the same value as
write ##class(DC.TestPerson).SalaryGetStored(id)
// the same game for serial classes
write ##class(DC.Address).PropInfo() --> Street,City
write ##class(DC.Address).PropInfo("City") --> 2
// in case you have an instance
set pers=##class(DC.TestPerson).%OpenId(id)
write pers.PropInfo() --> ,Name,Addr,Salary,Expertise
write pers.Addr.PropInfo() --> Street,City
// etc.
Certifications & Credly badges:
Julius has no Certifications & Credly badges yet.
Global Masters badges:







Followers:
Following:
Julius has not followed anybody yet.
In SystemManagementPortal goto:
SystemAdministration --> Configuration --> AdditionalSettings --> StartupSettings: JobServers