fix: minimize not set to false on all field type schemas
This commit is contained in:
@@ -335,6 +335,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
|
|||||||
options: {
|
options: {
|
||||||
_id: false,
|
_id: false,
|
||||||
id: false,
|
id: false,
|
||||||
|
minimize: false,
|
||||||
},
|
},
|
||||||
disableUnique: buildSchemaOptions.disableUnique,
|
disableUnique: buildSchemaOptions.disableUnique,
|
||||||
draftsEnabled: buildSchemaOptions.draftsEnabled,
|
draftsEnabled: buildSchemaOptions.draftsEnabled,
|
||||||
@@ -364,7 +365,11 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
|
|||||||
config,
|
config,
|
||||||
field.fields,
|
field.fields,
|
||||||
{
|
{
|
||||||
options: { _id: false, id: false },
|
options: {
|
||||||
|
_id: false,
|
||||||
|
id: false,
|
||||||
|
minimize: false,
|
||||||
|
},
|
||||||
allowIDField: true,
|
allowIDField: true,
|
||||||
disableUnique: buildSchemaOptions.disableUnique,
|
disableUnique: buildSchemaOptions.disableUnique,
|
||||||
draftsEnabled: buildSchemaOptions.draftsEnabled,
|
draftsEnabled: buildSchemaOptions.draftsEnabled,
|
||||||
@@ -388,6 +393,7 @@ const fieldToSchemaMap: Record<string, FieldSchemaGenerator> = {
|
|||||||
options: {
|
options: {
|
||||||
_id: false,
|
_id: false,
|
||||||
id: false,
|
id: false,
|
||||||
|
minimize: false,
|
||||||
},
|
},
|
||||||
disableUnique: buildSchemaOptions.disableUnique,
|
disableUnique: buildSchemaOptions.disableUnique,
|
||||||
draftsEnabled: buildSchemaOptions.draftsEnabled,
|
draftsEnabled: buildSchemaOptions.draftsEnabled,
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ type JSONField = {
|
|||||||
|
|
||||||
const JSON: CollectionConfig = {
|
const JSON: CollectionConfig = {
|
||||||
slug: 'json-fields',
|
slug: 'json-fields',
|
||||||
|
versions: {
|
||||||
|
maxPerDoc: 1,
|
||||||
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'json',
|
name: 'json',
|
||||||
|
|||||||
@@ -529,7 +529,7 @@ describe('Fields', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should save empty json objects', async () => {
|
it('should save empty json objects', async () => {
|
||||||
const createdJSON = await payload.create({
|
const jsonFieldsDoc = await payload.create({
|
||||||
collection: 'json-fields',
|
collection: 'json-fields',
|
||||||
data: {
|
data: {
|
||||||
json: {
|
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 updatedJsonFieldsDoc = await payload.update({
|
||||||
const jsonClient = new RESTClient(config, { serverURL, defaultSlug: 'json-fields' });
|
collection: 'json-fields',
|
||||||
await jsonClient.login();
|
id: jsonFieldsDoc.id,
|
||||||
|
|
||||||
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,
|
|
||||||
data: {
|
data: {
|
||||||
json: {
|
json: {
|
||||||
state: {},
|
state: {},
|
||||||
@@ -569,7 +550,7 @@ describe('Fields', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(doc.json.state).toEqual({});
|
expect(updatedJsonFieldsDoc.json.state).toEqual({});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -57,19 +57,6 @@ describe('globals', () => {
|
|||||||
expect(doc.array).toMatchObject(array);
|
expect(doc.array).toMatchObject(array);
|
||||||
expect(doc.id).toBeDefined();
|
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', () => {
|
describe('local', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user