Get Property MaxLen
Set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(table)
Set count = cdef.Properties.Count()
For i = 1:1:count {
Write cdef.Properties.GetAt(i).Name, " ", cdef.Properties.GetAt(i).Type, "", <MY QUESTION>,!
}
How can I do to get maxlen?
cdef.Properties.GetAt(i).Parameters.GetAt("MAXLEN")
in class %Dictionary.CompiledProperty you have
.png)
if a Property Parameter exists it is in this Array:
But not all properties have MAXLEN this is a %String
Not worked. I my string property has maxlen defined but parameters not contains the element MAXLEN
Is it really %String or a subtype without MAXLEN or MALXEN disabled ?
I have done this in past and I know of some types just defined to remove MAXLEN =50
e.g. %Library.RawString, %Library.Text, ...
Class dbml.DictToDBML
{
ClassMethod WriteDBML(schema As %String = "") As %Status
{
Set stmt = ##class(%SQL.Statement).%New()
Set status = stmt.%PrepareClassQuery("%Dictionary.CompiledClass","Summary")
If $$$ISERR(status) {
Do $System.Status.DisplayError(status)
Quit
}
Set rset = stmt.%Execute()
While (rset.%Next()) {
If rset.%Get("Persistent") = 1 {
Set table = rset.%Get("Name")
Set tableSchema = $Piece(table, ".", 1)
Set tableName = $Piece(table, ".", 2)
If tableSchema = schema {
Set cdef = ##class(%Dictionary.CompiledClass).%OpenId(table)
Write "Table ", tableName, " {",!
Write " ID integer [primary key] ",!
// get list of properties
Set count = cdef.Properties.Count()
For i = 1:1:count {
Set paramCount = cdef.Properties.GetAt(i).Parameters.Count()
//I checked Name property and it has MAXLEN
If (cdef.Properties.GetAt(i).Name = "Name") {
Write "MaxLen: ",cdef.Properties.GetAt(i).Parameters.GetAt("%MAXLEN"),!
}
Write cdef.Properties.GetAt(i).Name, " ", cdef.Properties.GetAt(i).Type, "", cdef.Properties.GetAt(i).Parameters.Count(),!
}
Write "}",!
}
}
}
Return $$$OK
}
}
why ("%MAXLEN"),! ???
it should be only ("MAXLEN"),! no %
Worked! '%' was my fault,
Thanks!!!
Get property parameter by global access:
/// Get property param /// w ##class().GetPropertyParam("Form.Test.Simple", "Name", "MAXLEN") ClassMethod GetPropertyParam(class As %Dictionary.CacheClassname = "", property As %String = "", param As %String = "") As %String [ CodeMode = expression ] { $$$comMemberArrayGet(class, $$$cCLASSproperty, property, $$$cPROPparameter, param) }