fix(db-sqlite): exists operator in createJSONQuery (#13907)
Fixes https://github.com/payloadcms/payload/issues/13882
This commit is contained in:
@@ -406,6 +406,66 @@ describe('Joins Field', () => {
|
||||
expect(findFolder?.docs[0]?.documentsAndFolders?.docs).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should query where with exists for hasMany select fields', async () => {
|
||||
await payload.delete({ collection: 'payload-folders', where: {} })
|
||||
const folderDoc = await payload.create({
|
||||
collection: 'payload-folders',
|
||||
data: {
|
||||
name: 'scopedFolder',
|
||||
folderType: ['folderPoly1', 'folderPoly2'],
|
||||
},
|
||||
})
|
||||
|
||||
await payload.create({
|
||||
collection: 'payload-folders',
|
||||
data: {
|
||||
name: 'childFolder',
|
||||
folderType: ['folderPoly1'],
|
||||
folder: folderDoc.id,
|
||||
},
|
||||
})
|
||||
|
||||
const findFolder = await payload.find({
|
||||
collection: 'payload-folders',
|
||||
where: {
|
||||
id: {
|
||||
equals: folderDoc.id,
|
||||
},
|
||||
},
|
||||
joins: {
|
||||
documentsAndFolders: {
|
||||
limit: 100_000,
|
||||
sort: 'name',
|
||||
where: {
|
||||
and: [
|
||||
{
|
||||
relationTo: {
|
||||
equals: 'payload-folders',
|
||||
},
|
||||
},
|
||||
{
|
||||
or: [
|
||||
{
|
||||
folderType: {
|
||||
in: ['folderPoly1'],
|
||||
},
|
||||
},
|
||||
{
|
||||
folderType: {
|
||||
exists: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
expect(findFolder?.docs[0]?.documentsAndFolders?.docs).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should filter joins using where query', async () => {
|
||||
const categoryWithPosts = await payload.findByID({
|
||||
id: category.id,
|
||||
|
||||
Reference in New Issue
Block a user