This PR fixes querying by a relationship field that has custom IDs in
`relationTo` with different types.
Now, in this case, we do cast the ID value in the database.
Example of the config / int test that reproduced the issue:
```ts
{
slug: 'posts-a',
fields: [],
},
{
slug: 'posts-b',
fields: [],
},
{
slug: 'posts-custom-id',
fields: [{ name: 'id', type: 'text' }],
},
{
slug: 'roots',
fields: [
{
name: 'rel',
relationTo: ['posts-a', 'posts-b', 'posts-custom-id'],
type: 'relationship',
},
],
},
```
```ts
const postA = await payload.create({ collection: 'posts-a', data: {} })
const postB = await payload.create({ collection: 'posts-b', data: {} })
const postC = await payload.create({
collection: 'posts-custom-id',
data: { id: crypto.randomUUID() },
})
const root_1 = await payload.create({
collection: 'roots',
data: {
rel: {
value: postC.id,
relationTo: 'posts-custom-id',
},
},
})
const res_1 = await payload.find({
collection: 'roots',
where: {
'rel.value': { equals: postC.id },
},
})
// COALESCE types integer and character varying cannot be matched
expect(res_1.totalDocs).toBe(1)
```
<!--
For external contributors, please include:
- A summary of the pull request and any related issues it fixes.
- Reasoning for the changes made or any additional context that may be
useful.
Ensure you have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.
-->
323 lines
7.2 KiB
TypeScript
323 lines
7.2 KiB
TypeScript
/* tslint:disable */
|
|
/* eslint-disable */
|
|
/**
|
|
* This file was automatically generated by Payload.
|
|
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,
|
|
* and re-run `payload generate:types` to regenerate this file.
|
|
*/
|
|
|
|
export interface Config {
|
|
auth: {
|
|
users: UserAuthOperations;
|
|
};
|
|
collections: {
|
|
posts: Post;
|
|
postsLocalized: PostsLocalized;
|
|
relation: Relation;
|
|
'strict-access': StrictAccess;
|
|
chained: Chained;
|
|
'custom-id': CustomId;
|
|
'custom-id-number': CustomIdNumber;
|
|
screenings: Screening;
|
|
movies: Movie;
|
|
directors: Director;
|
|
movieReviews: MovieReview;
|
|
'polymorphic-relationships': PolymorphicRelationship;
|
|
tree: Tree;
|
|
pages: Page;
|
|
'rels-to-pages': RelsToPage;
|
|
'rels-to-pages-and-custom-text-ids': RelsToPagesAndCustomTextId;
|
|
users: User;
|
|
'payload-preferences': PayloadPreference;
|
|
'payload-migrations': PayloadMigration;
|
|
};
|
|
db: {
|
|
defaultIDType: string;
|
|
};
|
|
globals: {};
|
|
locale: 'en' | 'de';
|
|
user: User & {
|
|
collection: 'users';
|
|
};
|
|
}
|
|
export interface UserAuthOperations {
|
|
forgotPassword: {
|
|
email: string;
|
|
password: string;
|
|
};
|
|
login: {
|
|
email: string;
|
|
password: string;
|
|
};
|
|
registerFirstUser: {
|
|
email: string;
|
|
password: string;
|
|
};
|
|
unlock: {
|
|
email: string;
|
|
password: string;
|
|
};
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "posts".
|
|
*/
|
|
export interface Post {
|
|
id: string;
|
|
title?: string | null;
|
|
description?: string | null;
|
|
number?: number | null;
|
|
relationField?: (string | null) | Relation;
|
|
defaultAccessRelation?: (string | null) | StrictAccess;
|
|
chainedRelation?: (string | null) | Chained;
|
|
maxDepthRelation?: (string | null) | Relation;
|
|
customIdRelation?: (string | null) | CustomId;
|
|
customIdNumberRelation?: (number | null) | CustomIdNumber;
|
|
filteredRelation?: (string | null) | Relation;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "relation".
|
|
*/
|
|
export interface Relation {
|
|
id: string;
|
|
name?: string | null;
|
|
disableRelation: boolean;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "strict-access".
|
|
*/
|
|
export interface StrictAccess {
|
|
id: string;
|
|
name?: string | null;
|
|
disableRelation: boolean;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "chained".
|
|
*/
|
|
export interface Chained {
|
|
id: string;
|
|
name?: string | null;
|
|
relation?: (string | null) | Chained;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "custom-id".
|
|
*/
|
|
export interface CustomId {
|
|
id: string;
|
|
name?: string | null;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "custom-id-number".
|
|
*/
|
|
export interface CustomIdNumber {
|
|
id: number;
|
|
name?: string | null;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "postsLocalized".
|
|
*/
|
|
export interface PostsLocalized {
|
|
id: string;
|
|
title?: string | null;
|
|
relationField?: (string | null) | Relation;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "screenings".
|
|
*/
|
|
export interface Screening {
|
|
id: string;
|
|
name?: string | null;
|
|
movie?: (string | null) | Movie;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "movies".
|
|
*/
|
|
export interface Movie {
|
|
id: string;
|
|
name?: string | null;
|
|
director?: (string | null) | Director;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "directors".
|
|
*/
|
|
export interface Director {
|
|
id: string;
|
|
name?: string | null;
|
|
movies?: (string | Movie)[] | null;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "movieReviews".
|
|
*/
|
|
export interface MovieReview {
|
|
id: string;
|
|
movieReviewer: string | User;
|
|
likes?: (string | User)[] | null;
|
|
visibility: 'followers' | 'public';
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "users".
|
|
*/
|
|
export interface User {
|
|
id: string;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
email: string;
|
|
resetPasswordToken?: string | null;
|
|
resetPasswordExpiration?: string | null;
|
|
salt?: string | null;
|
|
hash?: string | null;
|
|
loginAttempts?: number | null;
|
|
lockUntil?: string | null;
|
|
password?: string | null;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "polymorphic-relationships".
|
|
*/
|
|
export interface PolymorphicRelationship {
|
|
id: string;
|
|
polymorphic?: {
|
|
relationTo: 'movies';
|
|
value: string | Movie;
|
|
} | null;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "tree".
|
|
*/
|
|
export interface Tree {
|
|
id: string;
|
|
text?: string | null;
|
|
parent?: (string | null) | Tree;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "pages".
|
|
*/
|
|
export interface Page {
|
|
id: string;
|
|
menu?:
|
|
| {
|
|
label?: string | null;
|
|
id?: string | null;
|
|
}[]
|
|
| null;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "rels-to-pages".
|
|
*/
|
|
export interface RelsToPage {
|
|
id: string;
|
|
page?: (string | null) | Page;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "rels-to-pages-and-custom-text-ids".
|
|
*/
|
|
export interface RelsToPagesAndCustomTextId {
|
|
id: string;
|
|
rel?:
|
|
| ({
|
|
relationTo: 'pages';
|
|
value: string | Page;
|
|
} | null)
|
|
| ({
|
|
relationTo: 'custom-id';
|
|
value: string | CustomId;
|
|
} | null)
|
|
| ({
|
|
relationTo: 'custom-id-number';
|
|
value: number | CustomIdNumber;
|
|
} | null);
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "payload-preferences".
|
|
*/
|
|
export interface PayloadPreference {
|
|
id: string;
|
|
user: {
|
|
relationTo: 'users';
|
|
value: string | User;
|
|
};
|
|
key?: string | null;
|
|
value?:
|
|
| {
|
|
[k: string]: unknown;
|
|
}
|
|
| unknown[]
|
|
| string
|
|
| number
|
|
| boolean
|
|
| null;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "payload-migrations".
|
|
*/
|
|
export interface PayloadMigration {
|
|
id: string;
|
|
name?: string | null;
|
|
batch?: number | null;
|
|
updatedAt: string;
|
|
createdAt: string;
|
|
}
|
|
/**
|
|
* This interface was referenced by `Config`'s JSON-Schema
|
|
* via the `definition` "auth".
|
|
*/
|
|
export interface Auth {
|
|
[k: string]: unknown;
|
|
}
|
|
|
|
|
|
declare module 'payload' {
|
|
// @ts-ignore
|
|
export interface GeneratedTypes extends Config {}
|
|
} |