fix: minimize not set to false on all field type schemas

This commit is contained in:
Jarrod Flesch
2023-03-06 16:07:07 -05:00
parent c5f9fa0d97
commit ace032ef89
4 changed files with 16 additions and 39 deletions

View File

@@ -335,6 +335,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
options: {
_id: false,
id: false,
minimize: false,
},
disableUnique: buildSchemaOptions.disableUnique,
draftsEnabled: buildSchemaOptions.draftsEnabled,
@@ -364,7 +365,11 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
config,
field.fields,
{
options: { _id: false, id: false },
options: {
_id: false,
id: false,
minimize: false,
},
allowIDField: true,
disableUnique: buildSchemaOptions.disableUnique,
draftsEnabled: buildSchemaOptions.draftsEnabled,
@@ -388,6 +393,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
options: {
_id: false,
id: false,
minimize: false,
},
disableUnique: buildSchemaOptions.disableUnique,
draftsEnabled: buildSchemaOptions.draftsEnabled,

View File

@@ -10,6 +10,9 @@ type JSONField = {
const JSON: CollectionConfig = {
slug: 'json-fields',
versions: {
maxPerDoc: 1,
},
fields: [
{
name: 'json',

View File

@@ -529,7 +529,7 @@ describe('Fields', () => {
});
it('should save empty json objects', async () => {
const createdJSON = await payload.create({
const jsonFieldsDoc = await payload.create({
collection: 'json-fields',
data: {
json: {
@@ -538,30 +538,11 @@ describe('Fields', () => {
},
});
expect(createdJSON.json.state).toEqual({});
});
expect(jsonFieldsDoc.json.state).toEqual({});
it('should save empty json objects via REST', async () => {
const jsonClient = new RESTClient(config, { serverURL, defaultSlug: 'json-fields' });
await jsonClient.login();
const { doc: ogDoc } = await jsonClient.create({
auth: true,
data: {
json: {
empty: {},
state: {
foo: 'bar',
},
},
},
});
expect(ogDoc.json.empty).toEqual({});
const { doc } = await jsonClient.update({
auth: true,
id: ogDoc.id,
const updatedJsonFieldsDoc = await payload.update({
collection: 'json-fields',
id: jsonFieldsDoc.id,
data: {
json: {
state: {},
@@ -569,7 +550,7 @@ describe('Fields', () => {
},
});
expect(doc.json.state).toEqual({});
expect(updatedJsonFieldsDoc.json.state).toEqual({});
});
});

View File

@@ -57,19 +57,6 @@ describe('globals', () => {
expect(doc.array).toMatchObject(array);
expect(doc.id).toBeDefined();
});
it('should save empty json objects', async () => {
const { doc } = await client.updateGlobal({
slug,
data: {
json: {
state: {},
},
},
});
expect(doc.json.state).toEqual({});
});
});
describe('local', () => {