Skip to content

Commit 736a2c4

Browse files
author
Shubham Agarwal
committed
Accept nullable SourceType for ordinary columns
Treat Dataverse null SourceType as valid for ordinary Memo and Lookup metadata while retaining fail-closed validation for specialized columns. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78870709-25fe-45d7-8669-dd0ba9470807
1 parent 986fc79 commit 736a2c4

2 files changed

Lines changed: 69 additions & 2 deletions

File tree

plugins/mobile-apps/scripts/build-dataverse-operation-manifest.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ const DERIVED_COLUMN_TYPES = new Set([
5050
'lookup',
5151
'computed',
5252
]);
53+
const NULL_SOURCE_TYPE_IS_ORDINARY_TYPES = new Set([
54+
'lookup',
55+
'memo',
56+
'multiline',
57+
]);
5358

5459
function parseArgs(argv) {
5560
const args = {};
@@ -1110,9 +1115,13 @@ function baseColumnCompatibility(column, liveColumn) {
11101115
);
11111116
}
11121117
}
1113-
if (!hasOwn(liveColumn, 'sourceType') || liveColumn.sourceType === null) {
1118+
const normalizedColumnType = normalizeColumnType(column.type);
1119+
if (!hasOwn(liveColumn, 'sourceType')) {
1120+
reasons.push('SourceType evidence is missing');
1121+
} else if (liveColumn.sourceType === null
1122+
&& !NULL_SOURCE_TYPE_IS_ORDINARY_TYPES.has(normalizedColumnType)) {
11141123
reasons.push('SourceType evidence is missing');
1115-
} else if (!DERIVED_COLUMN_TYPES.has(normalizeColumnType(column.type))
1124+
} else if (!DERIVED_COLUMN_TYPES.has(normalizedColumnType)
11161125
&& Number(liveColumn.sourceType) !== 0) {
11171126
reasons.push(`ordinary column has SourceType ${liveColumn.sourceType}`);
11181127
}

plugins/mobile-apps/scripts/tests/dataverse-operation-manifest.test.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,64 @@ test('ordinary-column reuse requires complete compatible behavior evidence', ()
12871287
}
12881288
});
12891289

1290+
test('ordinary Memo and Lookup columns accept nullable Dataverse SourceType', () => {
1291+
const lookupReconciliation = fullyAppliedSnapshot();
1292+
lookupReconciliation.tables
1293+
.find((tableValue) => tableValue.logicalName === 'cr1_item')
1294+
.columns
1295+
.find((columnValue) => columnValue.logicalName === 'cr1_categoryid')
1296+
.sourceType = null;
1297+
const lookupManifest = buildManifest(buildInputs(
1298+
createContract(),
1299+
lookupReconciliation,
1300+
));
1301+
assert.equal(lookupManifest.executable, true);
1302+
assert.equal(lookupManifest.summary.metadataOperationCount, 0);
1303+
1304+
const memoContract = {
1305+
schemaVersion: 1,
1306+
publisherPrefix: 'cr1',
1307+
tables: [
1308+
contractTable('cr1_note', 'extend', 0, [
1309+
contractColumn('cr1_name', 'string', 'reuse', { primaryName: true }),
1310+
contractColumn('cr1_description', 'memo', 'reuse', {
1311+
maxLength: 10000,
1312+
format: 'TextArea',
1313+
}),
1314+
]),
1315+
],
1316+
};
1317+
const memoManifest = buildManifest(buildInputs(memoContract, snapshot({
1318+
tables: [table('cr1_note', [
1319+
column('cr1_name', 'String', { primaryName: true }),
1320+
column('cr1_description', 'Memo', { sourceType: null }),
1321+
])],
1322+
})));
1323+
assert.equal(memoManifest.executable, true);
1324+
assert.equal(memoManifest.summary.metadataOperationCount, 0);
1325+
1326+
const stringWithNullSourceType = column('cr1_name', 'String', {
1327+
primaryName: true,
1328+
sourceType: null,
1329+
});
1330+
const blocked = buildManifest(buildInputs({
1331+
schemaVersion: 1,
1332+
publisherPrefix: 'cr1',
1333+
tables: [
1334+
contractTable('cr1_note', 'extend', 0, [
1335+
contractColumn('cr1_name', 'string', 'reuse', { primaryName: true }),
1336+
]),
1337+
],
1338+
}, snapshot({
1339+
tables: [table('cr1_note', [stringWithNullSourceType])],
1340+
})));
1341+
assert.equal(blocked.executable, false);
1342+
assert.match(
1343+
blocked.decisions.find((item) => item.itemType === 'column').reason,
1344+
/SourceType evidence is missing/,
1345+
);
1346+
});
1347+
12901348
test('ordinary-column precision, range, date behavior, and primary-name constraints are enforced', () => {
12911349
const contract = {
12921350
schemaVersion: 1,

0 commit comments

Comments
 (0)