Currently we are using an ERD diagram to model a table within Cloud Spanner however VP doesn’t support the required data types within a given ERD table; therefore we thought about using the User Type field to overcome this problem.
To automate this process, I have created a plugin that takes a selected table in an ERD and maps the data type from MySQL to a Cloud Spanner data type equivalent. eg; int = INT64
Currently I can iterate over all the tables in a given ERD diagram, iterate over each column and extract certain properties eg;
IDiagramElement[] els = diag.getSelectedDiagramElement("DBTable");
IDBTable table = null;
for (IDiagramElement el : els) {
try {
table = (IDBTable) el.getModelElement();
IDBColumn[] columns = table.toDBColumnArray();
for (IDBColumn col : columns) {
System.out.println(col.getName() + " ,type: " + col.getType() + ", " + col.getTypeInText());
IDBColumnUserType colUserType = null;
if (col.toUserTypeArray().length > 0) {
//if user type already exists, print out the user type
System.out.println(col.getUserTypeByIndex(0).getType());
} else {
if (col.getType() == 9) { // int
//I want to set the user type here
//eg; colUserType.setType("INT64");
}
// col.addUserType(colUserType); ?
}
} catch (Error err) {}
}
However I can’t quite figure out how to create a new IDBColumnUserType instance.
IModelElementFactory.instance().createDBColumnUserType()
is the method to use to create a user type, but we are asking our team to provide more information about how to use the user type being created. We will come back to you when there is any news. Meanwhile, I will remind our teammates about your case.
Thanks for responding! Has this patch update been released for v16.1? I have tried to update but it says Im currently running the latest patch build. I’m currently running build: 20220101
We have made the change available in version 16.1. You can obtain it by updating your installation to the latest patch build (16_1_20220110ab or newer).