Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ const CollectionHeaderActions: React.FunctionComponent<
{schemaAnalysisError &&
schemaAnalysisError.errorType === 'unsupportedState' && (
<span className={tooltipMessageStyles}>
This collection has a field with a name that contains a
&quot.&quot, which mock data generation does not support at
this time.
{schemaAnalysisError.errorMessage}
</span>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,120 @@ describe('processSchema', function () {
};

expect(() => processSchema(schema)).to.throw(
"invalid fieldPath '[]': field parts must have characters other than '[]'"
ProcessSchemaUnsupportedStateError,
"no support for field names that end with '[]'; field name: '[]'"
);
});

it('throws error for field names ending with []', function () {
const schema: Schema = {
fields: [
{
name: 'users[]',
path: ['users[]'],
count: 1,
type: ['String'],
probability: 1.0,
hasDuplicates: false,
types: [
{
name: 'String',
bsonType: 'String',
path: ['users[]'],
count: 1,
probability: 1.0,
values: ['test'],
},
],
},
],
count: 1,
};

expect(() => processSchema(schema)).to.throw(
ProcessSchemaUnsupportedStateError,
"no support for field names that end with '[]'; field name: 'users[]'"
);
});

it('throws error for nested field names ending with []', function () {
const schema: Schema = {
fields: [
{
name: 'parent',
path: ['parent'],
count: 1,
type: ['Document'],
probability: 1.0,
hasDuplicates: false,
types: [
{
name: 'Document',
bsonType: 'Document',
path: ['parent'],
count: 1,
probability: 1.0,
fields: [
{
name: 'child[]',
path: ['parent', 'child[]'],
count: 1,
type: ['String'],
probability: 1.0,
hasDuplicates: false,
types: [
{
name: 'String',
bsonType: 'String',
path: ['parent', 'child[]'],
count: 1,
probability: 1.0,
values: ['test'],
},
],
},
],
},
],
},
],
count: 1,
};

expect(() => processSchema(schema)).to.throw(
ProcessSchemaUnsupportedStateError,
"no support for field names that end with '[]'; field name: 'child[]'"
);
});

it('throws error for field names containing dots', function () {
const schema: Schema = {
fields: [
{
name: 'user.name',
path: ['user.name'],
count: 1,
type: ['String'],
probability: 1.0,
hasDuplicates: false,
types: [
{
name: 'String',
bsonType: 'String',
path: ['user.name'],
count: 1,
probability: 1.0,
values: ['test'],
},
],
},
],
count: 1,
};

expect(() => processSchema(schema)).to.throw(
ProcessSchemaUnsupportedStateError,
"no support for field names that contain a '.' ; field name: 'user.name'"
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ function processNamedField(
);
}

if (field.name.endsWith('[]')) {
throw new ProcessSchemaUnsupportedStateError(
`no support for field names that end with '[]'; field name: '${field.name}'`
);
}

const currentPath = pathPrefix ? `${pathPrefix}.${field.name}` : field.name;

// Process based on the type
Expand Down
Loading