fix(db-postgres): fully functional dbNames (#6023)
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user