jwiesel / sfdcCommander

Helper for salesforce.com administrators. Download metadata, gernerate technical documentations and backup the database of an Org.
MIT License
17 stars 5 forks source link

Org-Backup: Implement different table column types based on field-types #13

Closed jwiesel closed 8 years ago

jwiesel commented 8 years ago

Right now every column is set to "text" instead of the correct sfdc-field-type. This should be changed.

jwiesel commented 8 years ago

Example Idea:

        for (int i = 0; i < tmpDescribeSObject.getFields().length; i++) {

            if (!tmpDescribeSObject.getFields()[i].getName().matches("Commit"))

            {

             createStatement.append("" + tmpDescribeSObject.getFields()[i].getName() + " ");

            if (tmpDescribeSObject.getFields()[i].getType().toString()=="date")

            createStatement.append(convertSfdcFieldType("Date") + ",");

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="_boolean")

            createStatement.append(convertSfdcFieldType("bit") + ","); 

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="textarea")

            createStatement.append(convertSfdcFieldType("nvarchar(MAX)") + ",");

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="datetime")

            createStatement.append(convertSfdcFieldType("DateTime") + ",");

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="_double")

            createStatement.append(convertSfdcFieldType("Float") + ",");

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="_int")

            createStatement.append(convertSfdcFieldType("Int") + ",");

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="currency")

            createStatement.append(convertSfdcFieldType("Money") + ",");

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="percent")

            createStatement.append(convertSfdcFieldType("decimal(5,2)") + ",");

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="base64")

            createStatement.append(convertSfdcFieldType("nvarchar(MAX)") + ",");

            else if (tmpDescribeSObject.getFields()[i].getType().toString()=="time")

            createStatement.append(convertSfdcFieldType("time") + ",");

            else {

            Integer test = tmpDescribeSObject.getFields()[i].getLength();

            if (test>=4000) test = 4000;

            createStatement.append(convertSfdcFieldType("nvarchar("+test.toString()+")") + ",");

            }

            }

        }