fix(db-postgres): fully functional dbNames (#6023)

This commit is contained in:
James Mikrut
2024-04-24 22:42:24 -04:00
committed by GitHub
parent 5f7af5317a
commit 629d7c3263
33 changed files with 231 additions and 227 deletions

View File

@@ -45,6 +45,10 @@ export default buildConfigWithDefaults({
{
slug: 'relation-a',
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'relationship',
type: 'relationship',
@@ -63,6 +67,10 @@ export default buildConfigWithDefaults({
{
slug: 'relation-b',
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'relationship',
type: 'relationship',

View File

@@ -214,6 +214,54 @@ describe('database', () => {
expect(db.enums.radioEnum).toBeDefined()
}
})
it('should create and read doc with custom db names', async () => {
const relationA = await payload.create({
collection: 'relation-a',
data: {
title: 'hello',
},
})
const { id } = await payload.create({
collection: 'custom-schema',
data: {
text: 'test',
relationship: [relationA.id],
localizedText: 'hello',
select: ['a', 'b'],
radio: 'a',
array: [
{
text: 'hello',
localizedText: 'goodbye',
},
],
blocks: [
{
blockType: 'block',
text: 'hello',
localizedText: 'goodbye',
},
],
},
})
const doc = await payload.findByID({
collection: 'custom-schema',
id,
})
expect(doc.relationship[0].title).toStrictEqual(relationA.title)
expect(doc.text).toStrictEqual('test')
expect(doc.localizedText).toStrictEqual('hello')
expect(doc.select).toHaveLength(2)
expect(doc.radio).toStrictEqual('a')
expect(doc.array[0].text).toStrictEqual('hello')
expect(doc.array[0].localizedText).toStrictEqual('goodbye')
expect(doc.blocks[0].text).toStrictEqual('hello')
expect(doc.blocks[0].localizedText).toStrictEqual('goodbye')
})
})
describe('transactions', () => {