mirror of https://github.com/apache/druid.git
treat null as not defined (#10751)
This commit is contained in:
parent
4437c6af60
commit
e52db19823
|
@ -19,6 +19,8 @@
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { COMPACTION_CONFIG_FIELDS } from '../../druid-models';
|
||||||
|
|
||||||
import { AutoForm } from './auto-form';
|
import { AutoForm } from './auto-form';
|
||||||
|
|
||||||
describe('AutoForm', () => {
|
describe('AutoForm', () => {
|
||||||
|
@ -44,4 +46,78 @@ describe('AutoForm', () => {
|
||||||
);
|
);
|
||||||
expect(autoForm).toMatchSnapshot();
|
expect(autoForm).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('.issueWithModel', () => {
|
||||||
|
it('should find no issue when everything is fine', () => {
|
||||||
|
expect(AutoForm.issueWithModel({}, COMPACTION_CONFIG_FIELDS)).toBeUndefined();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
AutoForm.issueWithModel(
|
||||||
|
{
|
||||||
|
dataSource: 'ds',
|
||||||
|
taskPriority: 25,
|
||||||
|
inputSegmentSizeBytes: 419430400,
|
||||||
|
maxRowsPerSegment: null,
|
||||||
|
skipOffsetFromLatest: 'P4D',
|
||||||
|
tuningConfig: {
|
||||||
|
maxRowsInMemory: null,
|
||||||
|
maxBytesInMemory: null,
|
||||||
|
maxTotalRows: null,
|
||||||
|
splitHintSpec: null,
|
||||||
|
partitionsSpec: {
|
||||||
|
type: 'dynamic',
|
||||||
|
maxRowsPerSegment: 5000000,
|
||||||
|
maxTotalRows: null,
|
||||||
|
},
|
||||||
|
indexSpec: null,
|
||||||
|
indexSpecForIntermediatePersists: null,
|
||||||
|
maxPendingPersists: null,
|
||||||
|
pushTimeout: null,
|
||||||
|
segmentWriteOutMediumFactory: null,
|
||||||
|
maxNumConcurrentSubTasks: null,
|
||||||
|
maxRetry: null,
|
||||||
|
taskStatusCheckPeriodMs: null,
|
||||||
|
chatHandlerTimeout: null,
|
||||||
|
chatHandlerNumRetries: null,
|
||||||
|
maxNumSegmentsToMerge: null,
|
||||||
|
totalNumMergeTasks: null,
|
||||||
|
type: 'index_parallel',
|
||||||
|
forceGuaranteedRollup: false,
|
||||||
|
},
|
||||||
|
taskContext: null,
|
||||||
|
},
|
||||||
|
COMPACTION_CONFIG_FIELDS,
|
||||||
|
),
|
||||||
|
).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should find issue correctly', () => {
|
||||||
|
expect(AutoForm.issueWithModel(undefined as any, COMPACTION_CONFIG_FIELDS)).toEqual(
|
||||||
|
'model is undefined',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
AutoForm.issueWithModel(
|
||||||
|
{
|
||||||
|
dataSource: 'ds',
|
||||||
|
taskPriority: 25,
|
||||||
|
inputSegmentSizeBytes: 419430400,
|
||||||
|
skipOffsetFromLatest: 'P4D',
|
||||||
|
tuningConfig: {
|
||||||
|
partitionsSpec: {
|
||||||
|
type: 'dynamic',
|
||||||
|
maxRowsPerSegment: 5000000,
|
||||||
|
maxTotalRows: null,
|
||||||
|
},
|
||||||
|
totalNumMergeTasks: 5,
|
||||||
|
type: 'index_parallel',
|
||||||
|
forceGuaranteedRollup: false,
|
||||||
|
},
|
||||||
|
taskContext: null,
|
||||||
|
},
|
||||||
|
COMPACTION_CONFIG_FIELDS,
|
||||||
|
),
|
||||||
|
).toEqual('field tuningConfig.totalNumMergeTasks is defined but it should not be');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -122,7 +122,7 @@ export class AutoForm<T extends Record<string, any>> extends React.PureComponent
|
||||||
|
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
const fieldValue = deepGet(model, field.name);
|
const fieldValue = deepGet(model, field.name);
|
||||||
const fieldValueDefined = typeof fieldValue !== 'undefined';
|
const fieldValueDefined = fieldValue != null;
|
||||||
const fieldThatIsDefined = definedFields[field.name];
|
const fieldThatIsDefined = definedFields[field.name];
|
||||||
if (fieldThatIsDefined) {
|
if (fieldThatIsDefined) {
|
||||||
if (fieldThatIsDefined === field) {
|
if (fieldThatIsDefined === field) {
|
||||||
|
|
Loading…
Reference in New Issue