Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

setAllowMultiUpdate

$
0
0
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

Viewing all articles
Browse latest Browse all 4756

Trending Articles