Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-5919

Salesforce: Insert fails in case of tables with salesforce standard objects

    Details

    • Sprint:
      DV Sprint 61
    • Story Points:
      0.5
    • Steps to Reproduce:
      Hide

      1. add salesforce resource adapter in standalone-teiid.xml:

                      <resource-adapter id="salesforce-34">
                          <module slot="main" id="org.jboss.teiid.resource-adapter.salesforce-34"/>
                          <connection-definitions>
                              <connection-definition class-name="org.teiid.resource.adapter.salesforce.SalesForceManagedConnectionFactory" jndi-name="java:/salesforce34" enabled="true" use-java-context="true" pool-name="sfDS34">
                                 <config-property name="URL">
                                    https://login.salesforce.com/services/Soap/u/34.0
                                 </config-property>
                                 <config-property name="username">
                                    xxxxx
                                 </config-property>
                                 <config-property name="password">
                                    xxxxx
                                 </config-property>
                              </connection-definition>
                          </connection-definitions>
                      </resource-adapter>
      

      2. add sf34 model:

          <model visible="true" name="sf34">
              <source name="sf34" translator-name="mySalesforce-34" connection-jndi-name="java:/salesforce34"/>    
          </model>
          <translator name="mySalesforce-34" type="salesforce-34">
              <property name="SupportsNativeQueries" value="true"/>
          </translator>
      

      3. run the following command:

      INSERT INTO sf34.Contact
      ("LastName", "FirstName", "Salutation", "MailingStreet", "MailingCity", "MailingPostalCode", "MailingCountry")
      VALUES
      ('Hillrichsen', 'Suse', 'Mrs.', 'Frankfurter Allee 29', 'Berlin', '10247','Deutschland') ;;
      
      Show
      1. add salesforce resource adapter in standalone-teiid.xml: <resource-adapter id= "salesforce-34" > <module slot= "main" id= "org.jboss.teiid.resource-adapter.salesforce-34" /> <connection-definitions> <connection-definition class-name= "org.teiid.resource.adapter.salesforce.SalesForceManagedConnectionFactory" jndi-name= "java:/salesforce34" enabled= "true" use-java-context= "true" pool-name= "sfDS34" > <config-property name= "URL" > https://login.salesforce.com/services/Soap/u/34.0 </config-property> <config-property name= "username" > xxxxx </config-property> <config-property name= "password" > xxxxx </config-property> </connection-definition> </connection-definitions> </resource-adapter> 2. add sf34 model: <model visible= "true" name= "sf34" > <source name= "sf34" translator-name= "mySalesforce-34" connection-jndi-name= "java:/salesforce34" /> </model> <translator name= "mySalesforce-34" type= "salesforce-34" > <property name= "SupportsNativeQueries" value= "true" /> </translator> 3. run the following command: INSERT INTO sf34.Contact ( "LastName" , "FirstName" , "Salutation" , "MailingStreet" , "MailingCity" , "MailingPostalCode" , "MailingCountry" ) VALUES ( 'Hillrichsen' , 'Suse' , 'Mrs.' , 'Frankfurter Allee 29' , 'Berlin' , '10247' , 'Deutschland' ) ;;
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      Add ddl to the vdb to alter the affected columns to be auto_increment:

      alter table contacts alter column name type string not null auto_increment;

      Show
      Add ddl to the vdb to alter the affected columns to be auto_increment: alter table contacts alter column name type string not null auto_increment;

      Description

      An insert fails in the case of a Salesforce table with standard objects. For example, the Contact table (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contact.htm) in salesforce contains Name standard object: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_name.htm. The field can't be null, doesn't support create(), insert() and so on operations but should be filled automatically by salesforce. As a result when running the following query:

      INSERT INTO sf34.Contact
      ("LastName", "FirstName", "Salutation", "MailingStreet", "MailingCity", "MailingPostalCode", "MailingCountry")
      VALUES
      ('Hillrichsen', 'Suse', 'Mrs.', 'Frankfurter Allee 29', 'Berlin', '10247','Deutschland') ;;
      

      Teiid generates the following error:

      2020-03-16 16:35:15,105 WARN  [org.teiid.PROCESSOR] (Worker3_QueryProcessorQueue50) ij6teT/JNA+c TEIID30020 Processing exception for request ij6teT/JNA+c.18 'TEIID30492 Element sf34.Contact.Name of sf34.Contact is neither nullable nor has a default value. A value must be specified in the insert.'. Originally QueryValidatorException Request.java:343. Enable more detailed logging to see the entire stacktrace.
      

      The problem can be solved by a native call, for example:

      SELECT * FROM (call "sf34.native"('create;type=Contact;attributes=LastName,FirstName,Salutation,MailingStreet,MailingCity,MailingPostalCode,MailingCountry','Erich','Honecker','Herr','Magdalenenstr. 99','Berlin','11799','DE')) lpk ;;
      

      but it won't work with dates/timestamps types (no sample request available).

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  shawkins Steven Hawkins
                  Reporter:
                  dalex005 Dmitrii Pogorelov
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 2 hours Original Estimate - 2 hours
                    2h
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 2 hours, 30 minutes
                    2h 30m