Hi Isomorphic,
using current 6.1p (v11.1p_2017-11-16) it seems that setAllowMultiUpdate(false) is not behaving as documented.
It seems that almost always it is enough to just have primaryKey-field criteria, regardless of the operator.
The docs state:
This means, only requests with top-level equals-criteria should be allowed.
Please see this testcase (no actual delete is done, safe to run), which only disallows GreaterThanField, but allows GreaterOrEqual, EndsWith, NotEqual, NotNull.
DeleteTest.java (register in web.xml):
I'd expect all tests but the last one to fail.
Also, IMHO the docs for the default behavior are contradictory here, see the two bold parts.
the docs for defaultMultiUpdatePolicy:
(This is from framework.properties:)
These are the docs for enum MultiUpdatePolicy.RPCMANAGER:
Best regards
Blama
using current 6.1p (v11.1p_2017-11-16) it seems that setAllowMultiUpdate(false) is not behaving as documented.
It seems that almost always it is enough to just have primaryKey-field criteria, regardless of the operator.
The docs state:
Code:
Parameters: newValue - true to allow multi-updates; false to restrict updates so that they [B]can affect just one single record[/B], identified by primaryKey values in the record provided
Please see this testcase (no actual delete is done, safe to run), which only disallows GreaterThanField, but allows GreaterOrEqual, EndsWith, NotEqual, NotNull.
DeleteTest.java (register in web.xml):
Code:
package com.smartgwt.sample.server.listener; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.isomorphic.criteria.DefaultOperators; import com.isomorphic.datasource.DSRequest; import com.isomorphic.datasource.DataSource; public class DeleteTest extends HttpServlet { private static final long serialVersionUID = -536025913450167992L; @Override public void doGet(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { PrintWriter pw = servletResponse.getWriter(); try { DSRequest deleteReq = new DSRequest("supplyItem", DataSource.OP_REMOVE); deleteReq.setClientRequest(true); deleteReq.setAllowMultiUpdate(false); deleteReq.addToCriteria("itemID", DefaultOperators.GreaterOrEqual, 10000000); deleteReq.addToCriteria("SKU", DefaultOperators.Equals, "blockDelete"); deleteReq.execute(); } catch (Exception e) { pw.append("Failed GreaterOrEqual\r\n"); } try { DSRequest deleteReq = new DSRequest("supplyItem", DataSource.OP_REMOVE); deleteReq.setClientRequest(true); deleteReq.setAllowMultiUpdate(false); deleteReq.addToCriteria("itemID", DefaultOperators.GreaterThanField, "itemID"); deleteReq.addToCriteria("SKU", DefaultOperators.Equals, "blockDelete"); deleteReq.execute(); } catch (Exception e) { pw.append("Failed GreaterThanField\r\n"); } try { DSRequest deleteReq = new DSRequest("supplyItem", DataSource.OP_REMOVE); deleteReq.setClientRequest(true); deleteReq.setAllowMultiUpdate(false); deleteReq.addToCriteria("itemID", DefaultOperators.EndsWith, "0"); deleteReq.addToCriteria("SKU", DefaultOperators.Equals, "blockDelete"); deleteReq.execute(); } catch (Exception e) { pw.append("Failed EndsWith\r\n"); } try { DSRequest deleteReq = new DSRequest("supplyItem", DataSource.OP_REMOVE); deleteReq.setClientRequest(true); deleteReq.setAllowMultiUpdate(false); deleteReq.addToCriteria("itemID", DefaultOperators.NotEqual, "123456"); deleteReq.addToCriteria("SKU", DefaultOperators.Equals, "blockDelete"); deleteReq.execute(); } catch (Exception e) { pw.append("Failed NotEqual\r\n"); } try { DSRequest deleteReq = new DSRequest("supplyItem", DataSource.OP_REMOVE); deleteReq.setClientRequest(true); deleteReq.setAllowMultiUpdate(false); deleteReq.addToCriteria("itemID", DefaultOperators.NotNull); deleteReq.addToCriteria("SKU", DefaultOperators.Equals, "blockDelete"); deleteReq.execute(); } catch (Exception e) { pw.append("Failed NotNull\r\n"); } try { DSRequest deleteReq = new DSRequest("supplyItem", DataSource.OP_REMOVE); deleteReq.setClientRequest(true); deleteReq.setAllowMultiUpdate(false); deleteReq.addToCriteria("itemID", DefaultOperators.Equals, 10000000); deleteReq.addToCriteria("SKU", DefaultOperators.Equals, "blockDelete"); deleteReq.execute(); } catch (Exception e) { pw.append("Failed Equals - not expected\r\n"); } } }
Also, IMHO the docs for the default behavior are contradictory here, see the two bold parts.
the docs for defaultMultiUpdatePolicy:
Default value of null means this DataSource will use the system-wide default, which is set via datasources.defaultMultiUpdatePolicy in server.properties, and defaults to allowing multi updates for requests associated with an RPCManager, see MultiUpdatePolicy for details.
# if allowMultiUpdate is not set, having a PK is required for requests associated with an RPCManager
datasources.defaultMultiUpdatePolicy: rpcManager
datasources.defaultMultiUpdatePolicy: rpcManager
having a PK is required for any request that is associated with an RPCManager, which includes clientRequests and server-created DSRequests where an RPCManager was explicitly provided
Blama
Comment