Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    setAllowMultiUpdate

    I'm not sure if the actual behavior of the server-side setAllowMultiUpdate() is correct.

    I have this:
    Code:
    AdvancedCriteria deleteCriterion = new AdvancedCriteria(
    				DefaultOperators.Or,
    				deleteCriterions.toArray(new Criterion[] {}));
    		deleteRequest.setAdvancedCriteria(deleteCriterion);
    		
    		deleteRequest.execute();
    So having the default setAllowMultiUpdate=false.
    This SQL is being produced, IGNORING THE advancedCriteria (since it specifies a field different from the primary key):
    Code:
    DELETE FROM t_rel_vertrag_bildungsgang WHERE (''1''=''1'') select SCOPE_IDENTITY() AS GENERATED_KEYS
    So it is deleting THE WHOLE TABLE!!!!!
    In the documentation of setAllowMultiUpdate I read:
    Code:
    Sets an internal flag for this DSRequest to determine whether updates and deletes are allowed in the absence of primaryKey fields. The default of false: 
    -provides safeguards for server code
    what? safeguards for server code? I just deleted the whole table having the default of false!! So either the documentation is not accurate or the behavior.

    If I change my code to:
    Code:
    AdvancedCriteria deleteCriterion = new AdvancedCriteria(
    				DefaultOperators.Or,
    				deleteCriterions.toArray(new Criterion[] {}));
    		deleteRequest.setAdvancedCriteria(deleteCriterion);
    		deleteRequest.setAllowMultiUpdate(true);
    		deleteRequest.execute();
    Then the correct SQL is generated:
    Code:
    DELETE FROM t_rel_vertrag_bildungsgang WHERE (t_rel_vertrag_bildungsgang.f_vertrag = 8194 AND t_rel_vertrag_bildungsgang.f_vertrag IS NOT NULL) select SCOPE_IDENTITY() AS GENERATED_KEYS

    #2
    Hi edulid,

    this might be a bug in setAdvancedCriteria(), see this thread from July, where it also was caused by setAdvancedCriteria().
    To double check you could check the criteria in the debugger after applying them.

    In July, it was fixed for v9.1p. Where did you get the error?

    Best regards,
    Blama

    EDIT:

    Sorry, as it is working with setAllowMultiUpdate(true) I agree that it is more likely related to setAllowMultiUpdate()
    Last edited by Blama; 2 Mar 2015, 00:26.

    Comment


      #3
      This has been assigned to a developer to look into; we'll post on here when we have something more to say.

      Comment


        #4
        We do not reproduce this problem with your code running against one of the standard showcase dataSources. Please share your DataSource descriptor (.ds.xml file).

        Comment


          #5
          I am having the same issue with smartclient version 10. Whenever I do perform a delete on a table where the value in the criteria is not the primary key, smartclient ends up deleting everything in the table. It adds a where clause that is: WHERE ('1'='1'). Lost a lot of data because of this.

          Comment


            #6
            Hi henkiemaritz,

            I'm pretty sure Isomorphic is interested in all the relevant details:
            • exact version
            • .ds.xml file
            • client request from Developer Console
            • potential DMI java code
            • Server logs


            Best regards
            Blama

            Comment


              #7
              Quite true, but also we'd like to point that in order to prevent accidental data loss if you make a mistake in your UI, the default server behavior is to reject any update or delete operation that does not contain a primary key. To cause any data deletion you have to explicitly bypass this safety measure, such as by setting allowMultiUpdate=true, then failing to add any safety checks of your own.

              Comment


                #8
                Originally posted by edulid View Post
                I'm not sure if the actual behavior of the server-side setAllowMultiUpdate() is correct.

                I have this:
                Code:
                AdvancedCriteria deleteCriterion = new AdvancedCriteria(
                				DefaultOperators.Or,
                				deleteCriterions.toArray(new Criterion[] {}));
                		deleteRequest.setAdvancedCriteria(deleteCriterion);
                		
                		deleteRequest.execute();
                I didn't have allowMultiUpdate=true and the whole table is being deleted. As you see in my original post.

                Comment


                  #9
                  As noted earlier in this thread, we were not able to reproduce this problem and there was no response to our request for more information

                  We do not reproduce this problem with your code running against one of the standard showcase dataSources. Please share your DataSource descriptor (.ds.xml file).

                  Comment

                  Working...
                  X