Hello) I'm having a problem generating data in IRES, I'm using %Populate class inheritance, as well as the Popsec and VALUELIST properties. Here is my class:
Class User.Car Extends (%Persistent, %Populate)
{
/// Description
Property Brand As %String(POPSPEC = "ValueList("",Ford,Lada,BMW,Kia"")", VALUELIST = ",Ford,Lada,BMW,Kia");
/// Description
Property Name As %String(POPSPEC = "ValueList("",Focus,M6,Rio,Octavio"")", VALUELIST = ",Focus,M6,Rio,Octavio");
/// Description
Property Type As %String(POPSPEC = "ValueList("",SUV,sedan,liftback"")", VALUELIST = ",SUV,sedan,liftback");
/// Description
Property foundationDate As %DateTime(POPSPEC = "Date()");
/// Description
Property maxSpeed As %Numeric(POPSPEC = "Float(150,200,0)");
/// Description
Property enginePower As %Numeric(POPSPEC = "Float(50,400,0)");
/// Description
Relationship companyCar As User.Company [ Cardinality = one, Inverse = carsCompany ];
/// Description
Index companyCarIndex On companyCar;
Storage Default
{
<Data name="CarDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Name</Value>
</Value>
<Value name="3">
<Value>Type</Value>
</Value>
<Value name="4">
<Value>Brand</Value>
</Value>
<Value name="5">
<Value>foundationDate</Value>
</Value>
<Value name="6">
<Value>maxSpeed</Value>
</Value>
<Value name="7">
<Value>enginePower</Value>
</Value>
<Value name="8">
<Value>company</Value>
</Value>
<Value name="9">
<Value>Names</Value>
</Value>
<Value name="10">
<Value>companyCar</Value>
</Value>
</Data>
<DataLocation>^User.CarD</DataLocation>
<DefaultData>CarDefaultData</DefaultData>
<ExtentSize>20</ExtentSize>
<IdLocation>^User.CarD</IdLocation>
<IndexLocation>^User.CarI</IndexLocation>
<Property name="%%CLASSNAME">
<AverageFieldSize>1</AverageFieldSize>
<Selectivity>100.0000%</Selectivity>
</Property>
<Property name="%%ID">
<AverageFieldSize>1.55</AverageFieldSize>
<Selectivity>1</Selectivity>
</Property>
<Property name="Brand">
<AverageFieldSize>5</AverageFieldSize>
<Selectivity>16.6667%</Selectivity>
</Property>
<Property name="Name">
<AverageFieldSize>12</AverageFieldSize>
<Selectivity>9.0909%</Selectivity>
</Property>
<Property name="Type">
<AverageFieldSize>4.7</AverageFieldSize>
<Selectivity>33.3333%</Selectivity>
</Property>
<Property name="companyCar">
<AverageFieldSize>1.9</AverageFieldSize>
<Selectivity>16.6667%</Selectivity>
</Property>
<Property name="enginePower">
<AverageFieldSize>2.9</AverageFieldSize>
<Selectivity>6.6667%</Selectivity>
</Property>
<Property name="foundationDate">
<AverageFieldSize>19</AverageFieldSize>
<Selectivity>12.5000%</Selectivity>
</Property>
<Property name="maxSpeed">
<AverageFieldSize>3</AverageFieldSize>
<Selectivity>7.1429%</Selectivity>
</Property>
<SQLMap name="IDKEY">
<BlockCount>-4</BlockCount>
</SQLMap>
<SQLMap name="companyCarIndex">
<BlockCount>-4</BlockCount>
</SQLMap>
<StreamLocation>^User.CarS</StreamLocation>
<Type>%Storage.Persistent</Type>
}
}
But when I enter the command Do ##class(User.Car).Populate(5) in the terminal, nothing happens and no data is generated. If anyone knows what could be the problem, I would be very grateful if you could help me
A couple of comments. You have
/// Description Property Brand As %String(POPSPEC = "ValueList("",Ford,Lada,BMW,Kia"")", VALUELIST = ",Ford,Lada,BMW,Kia");
but you don't really need the POPSPEC=""ValueList("",Ford,Lada,BMW,Kia"")"
As by default using %Populate already handles %String fields when a VALUELIST is defined. To simplify things I would define this
/// Description Property Brand As %String(VALUELIST = ",Ford,Lada,BMW,Kia");
/// Description Property Name As %String(VALUELIST = ",Focus,M6,Rio,Octavio");
/// Description Property Type As %String(VALUELIST = ",SUV,sedan,liftback");
/// Description Property foundationDate As %DateTime();
/// Description Property maxSpeed As %Numeric(MINVAL=150,MAXVAL=200,SCALE=0);
/// Description Property enginePower As %Numeric(MINVAL=50,MAXVAL=400,SCALE=0);
if you look at the method documentation for Populate you'll see
classmethod Populate(count As %Integer = 10, verbose As %Integer = 0, DeferIndices As %Integer = 1, ByRef objects As %Integer = 0, tune As %Integer = 1, deterministic As %Integer = 0) as %Integer Creates up to count instances an object and stores them in the database. If verbose is true, then details are echoed to the console.
If DeferIndices is true, then indices are sorted at the end of the operation.
If objects is true, then each object that is created is returned in the objects array
If tune is true, then $SYSTEM.SQL.TuneTable is called after the instances of the class have been created. If tune>1, then $SYSTEM.SQL.TuneTable is also called for any tables projected by persistent superclasses of this class
If deterministic is true, then the set of objects produced by identical calls to Populate at different times will be identical.
Returns the number of instances successfully created.
For more information refer to The Populate Utility.
so you might consider calling .Populate with the verbose flag. I believe the primary issue is your POPSPEC on foundationDate as this field is a %DateTime but then you have a POPSPEC that sets this field as just a Date.