Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/drizzle/src/queries/getTableColumnFromPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ export const getTableColumnFromPath = ({

if (
Array.isArray(value) &&
value.length > 0 &&
value.every((val) => typeof val === 'number') &&
idTypeTextOrUuid
) {
Expand All @@ -749,6 +750,7 @@ export const getTableColumnFromPath = ({

if (
Array.isArray(value) &&
value.length > 0 &&
idType === 'uuid' &&
hasCustomCollectionWithCustomID &&
!value.some((val) => uuidValidate(val))
Expand Down
34 changes: 34 additions & 0 deletions test/relationships/int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,40 @@ describe('Relationships', () => {
})

describe('Polymorphic Relationships', () => {
it('should return no documents for an empty in query on a polymorphic relationship', async () => {
const movie = await payload.create({
collection: 'movies',
data: {
name: 'Empty in query movie',
},
})
const relationship = await payload.create({
collection: polymorphicRelationshipsSlug,
data: {
polymorphic: {
relationTo: 'movies',
value: movie.id,
},
},
})

try {
const result = await payload.find({
collection: polymorphicRelationshipsSlug,
where: {
'polymorphic.value': {
in: [],
},
},
})

expect(result.docs).toHaveLength(0)
} finally {
await payload.delete({ id: relationship.id, collection: polymorphicRelationshipsSlug })
await payload.delete({ id: movie.id, collection: 'movies' })
}
})

it('should allow REST querying on polymorphic relationships', async () => {
const movie = await payload.create({
collection: 'movies',
Expand Down
Loading