Skip to content

Commit 1dc7c81

Browse files
committed
rename fn
1 parent e5f0433 commit 1dc7c81

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

packages/compass-data-modeling/src/store/diagram.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { collectionToDiagramNode } from '../utils/nodes-and-edges';
3131
import toNS from 'mongodb-ns';
3232
import {
3333
getFieldFromSchema,
34-
getSchemaForNewTypes,
34+
getSchemaWithNewTypes,
3535
traverseSchema,
3636
} from '../utils/schema-traversal';
3737
import { applyEdit as _applyEdit } from './apply-edit';
@@ -703,7 +703,7 @@ export function changeFieldType(
703703
fieldPath: fieldPath,
704704
});
705705
if (!field) throw new Error('Field not found in schema');
706-
const to = getSchemaForNewTypes(field.jsonSchema, newTypes);
706+
const to = getSchemaWithNewTypes(field.jsonSchema, newTypes);
707707
dispatch(
708708
applyEdit({
709709
type: 'ChangeFieldType',

packages/compass-data-modeling/src/utils/schema-traversal.spec.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
traverseSchema,
44
getFieldFromSchema,
55
updateSchema,
6-
getSchemaForNewTypes,
6+
getSchemaWithNewTypes,
77
} from './schema-traversal';
88
import Sinon from 'sinon';
99

@@ -1055,17 +1055,17 @@ describe('renameField', function () {
10551055
});
10561056
});
10571057

1058-
describe('getSchemaForNewTypes', function () {
1058+
describe('getSchemaWithNewTypes', function () {
10591059
describe('basic types', function () {
10601060
it('updates a single type', function () {
10611061
const newTypes = ['string', 'int'];
1062-
const result = getSchemaForNewTypes({ bsonType: 'string' }, newTypes);
1062+
const result = getSchemaWithNewTypes({ bsonType: 'string' }, newTypes);
10631063
expect(result).to.deep.equal({ bsonType: newTypes });
10641064
});
10651065

10661066
it('updates an array of types', function () {
10671067
const newTypes = ['bool', 'int'];
1068-
const result = getSchemaForNewTypes(
1068+
const result = getSchemaWithNewTypes(
10691069
{ bsonType: ['string', 'bool'] },
10701070
newTypes
10711071
);
@@ -1077,7 +1077,7 @@ describe('getSchemaForNewTypes', function () {
10771077
describe('cleans up the root schema', function () {
10781078
it('changes an object to a string', function () {
10791079
const newTypes = ['string'];
1080-
const result = getSchemaForNewTypes(
1080+
const result = getSchemaWithNewTypes(
10811081
{
10821082
bsonType: 'object',
10831083
properties: {
@@ -1092,7 +1092,7 @@ describe('getSchemaForNewTypes', function () {
10921092

10931093
it('changes an array to a string', function () {
10941094
const newTypes = ['string'];
1095-
const result = getSchemaForNewTypes(
1095+
const result = getSchemaWithNewTypes(
10961096
{
10971097
bsonType: 'array',
10981098
items: {
@@ -1128,7 +1128,7 @@ describe('getSchemaForNewTypes', function () {
11281128
},
11291129
],
11301130
};
1131-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1131+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
11321132
// array is no longer part of anyOf, now it is the only type and so the root schema
11331133
expect(result).to.deep.equal(oldSchema.anyOf[1]);
11341134
});
@@ -1155,7 +1155,7 @@ describe('getSchemaForNewTypes', function () {
11551155
},
11561156
],
11571157
};
1158-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1158+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
11591159
// object is no longer part of anyOf, now it is the only type and so the root schema
11601160
expect(result).to.deep.equal(oldSchema.anyOf[0]);
11611161
});
@@ -1184,7 +1184,7 @@ describe('getSchemaForNewTypes', function () {
11841184
},
11851185
],
11861186
};
1187-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1187+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
11881188
expect(result).not.to.have.property('bsonType');
11891189
expect(result.anyOf).to.have.lengthOf(3);
11901190
expect(result.anyOf).to.have.deep.members([
@@ -1201,7 +1201,7 @@ describe('getSchemaForNewTypes', function () {
12011201
const oldSchema = {
12021202
bsonType: 'string',
12031203
};
1204-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1204+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
12051205
expect(result).not.to.have.property('bsonType');
12061206
expect(result.anyOf).to.have.lengthOf(2);
12071207
expect(result.anyOf).to.deep.include({
@@ -1219,7 +1219,7 @@ describe('getSchemaForNewTypes', function () {
12191219
const oldSchema = {
12201220
bsonType: 'string',
12211221
};
1222-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1222+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
12231223
expect(result).not.to.have.property('bsonType');
12241224
expect(result.anyOf).to.have.lengthOf(2);
12251225
expect(result.anyOf).to.deep.include({
@@ -1240,7 +1240,7 @@ describe('getSchemaForNewTypes', function () {
12401240
},
12411241
required: ['name'],
12421242
};
1243-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1243+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
12441244
expect(result).not.to.have.property('bsonType');
12451245
expect(result).not.to.have.property('properties');
12461246
expect(result).not.to.have.property('required');
@@ -1259,7 +1259,7 @@ describe('getSchemaForNewTypes', function () {
12591259
bsonType: 'array',
12601260
items: { bsonType: 'int' },
12611261
};
1262-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1262+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
12631263
expect(result).not.to.have.property('bsonType');
12641264
expect(result).not.to.have.property('items');
12651265
expect(result.anyOf).to.have.lengthOf(2);
@@ -1289,7 +1289,7 @@ describe('getSchemaForNewTypes', function () {
12891289
},
12901290
],
12911291
};
1292-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1292+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
12931293
expect(result).not.to.have.property('anyOf');
12941294
expect(result).to.deep.equal({ bsonType: newTypes });
12951295
});
@@ -1313,7 +1313,7 @@ describe('getSchemaForNewTypes', function () {
13131313
},
13141314
],
13151315
};
1316-
const result = getSchemaForNewTypes(oldSchema, newTypes);
1316+
const result = getSchemaWithNewTypes(oldSchema, newTypes);
13171317
expect(result).not.to.have.property('anyOf');
13181318
expect(result).to.deep.equal({ bsonType: newTypes });
13191319
});

packages/compass-data-modeling/src/utils/schema-traversal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ const getOtherVariants = (
363363
return [...existingAnyOfVariants, ...existingBasicVariants, ...newVariants];
364364
};
365365

366-
export function getSchemaForNewTypes(
366+
export function getSchemaWithNewTypes(
367367
oldSchema: MongoDBJSONSchema,
368368
newTypes: string[]
369369
): MongoDBJSONSchema {

0 commit comments

Comments
 (0)