Skip to content

Commit 18eae9d

Browse files
committed
[INTERNAL] sap.ui.model.odata.v4.ODataModel: make synchronizationMode optional
PS1: downport Change-Id: I9cda5c7094a0591bffe568b535b11c8682ed6e62 CR-Id: 002075125900004730852025 SNOW: CS20250011008073
1 parent 8265c9f commit 18eae9d

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/sap.ui.core/src/sap/ui/model/odata/v4/ODataModel.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ sap.ui.define([
133133
* Whether <code>&lt;edmx:Reference></code> and <code>&lt;edmx:Include></code> directives are
134134
* supported in order to load schemas on demand from other $metadata documents and include
135135
* them into the current service ("cross-service references").
136-
* @param {string} mParameters.synchronizationMode
136+
* @param {string} [mParameters.synchronizationMode]
137137
* Controls synchronization between different bindings which refer to the same data for the
138138
* case data changes in one binding. Must be set to 'None' which means bindings are not
139139
* synchronized at all; all other values are not supported and lead to an error.
@@ -205,7 +205,9 @@ sap.ui.define([
205205
// do not pass any parameters to Model
206206
Model.apply(this);
207207

208-
if (!mParameters || mParameters.synchronizationMode !== "None") {
208+
mParameters = mParameters || {};
209+
if ("synchronizationMode" in mParameters
210+
&& mParameters.synchronizationMode !== "None") {
209211
throw new Error("Synchronization mode must be 'None'");
210212
}
211213
sODataVersion = mParameters.odataVersion || "4.0";

src/sap.ui.core/test/sap/ui/core/qunit/odata/v4/ODataModel.qunit.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ sap.ui.define([
7676
*/
7777
function createModel(sQuery, mParameters) {
7878
mParameters = jQuery.extend({}, mParameters, {
79-
serviceUrl : getServiceUrl() + (sQuery || ""),
80-
synchronizationMode : "None"
79+
serviceUrl : getServiceUrl() + (sQuery || "")
8180
});
8281
return new ODataModel(mParameters);
8382
}
@@ -120,20 +119,22 @@ sap.ui.define([
120119
mModelOptions = {};
121120

122121
assert.throws(function () {
123-
return new ODataModel();
122+
return new ODataModel({synchronizationMode : undefined});
123+
}, new Error("Synchronization mode must be 'None'"));
124+
assert.throws(function () {
125+
return new ODataModel({synchronizationMode : "Nope"});
124126
}, new Error("Synchronization mode must be 'None'"));
125127
assert.throws(function () {
126-
return new ODataModel({synchronizationMode : "None"});
128+
return new ODataModel();
127129
}, new Error("Missing service root URL"));
128130
assert.throws(function () {
129-
return new ODataModel({serviceUrl : "/foo", synchronizationMode : "None"});
131+
return new ODataModel({serviceUrl : "/foo"});
130132
}, new Error("Service root URL must end with '/'"));
131133
assert.throws(function () {
132-
return new ODataModel({synchronizationMode : "None", useBatch : true});
134+
return new ODataModel({useBatch : true});
133135
}, new Error("Unsupported parameter: useBatch"));
134136
assert.throws(function () {
135-
return new ODataModel({operationMode : OperationMode.Auto, serviceUrl : "/foo/",
136-
synchronizationMode : "None"});
137+
return new ODataModel({operationMode : OperationMode.Auto, serviceUrl : "/foo/"});
137138
}, new Error("Unsupported operation mode: Auto"), "Unsupported OperationMode");
138139
oModelPrototypeMock.expects("initializeSecurityToken").never();
139140

0 commit comments

Comments
 (0)