Creating a user type within ERD diagram

Festive greetings!

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.

Any help is much appreciated.

Hi GregS,

Thank you for your post. I have forwarded your inquiry to our team for further studying. When there is any news, I will let you know.

Best regards,
Jick Yeung

Hey @Jick, is there any update?

Hi GregS,

Sorry for being late.

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.

Best regards,
Jick Yeung

Hi GregS,

To support your need, we introduced a new method. Please update to the latest patch build and try using the call below:
IDBColumn.setUserType(string)

The following article shows you how to update:

Best regards,
Jick Yeung

Hi @Jick ,

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

Hi GregS,

The update was made to version 16.3, the latest version, only. I will ask our developers to review if we can support it in 16.1 as well.

Best regards,
Jick Yeung

Hi GregS,

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).

Best regards,
Jick Yeung

Thanks @Jick, that did the trick! :smiley:

You are welcome. :slight_smile: