Skip to content

Commit

Permalink
feat(client): add JSON filtering to Postgres and MySQL (#7114)
Browse files Browse the repository at this point in the history
Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
  • Loading branch information
williamluke4 and Jolg42 committed May 19, 2021
1 parent 722bdba commit ef2bfe4
Show file tree
Hide file tree
Showing 14 changed files with 1,256 additions and 36 deletions.
2 changes: 2 additions & 0 deletions src/packages/client/helpers/patchJest.js
Expand Up @@ -2,6 +2,7 @@ const resolveFrom = require('resolve-from')
const path = require('path')
const fs = require('fs')


const jestPath = require.resolve('jest')
const jestCliPath = resolveFrom(jestPath, 'jest-cli')
const jestUtilPath = resolveFrom(jestCliPath, 'jest-util')
Expand All @@ -15,3 +16,4 @@ lines[78] = ' globalObject.process = process'

const result = lines.join('\n')
fs.writeFileSync(patchFilePath, result)

Expand Up @@ -976,8 +976,37 @@ export namespace Prisma {
* From ts-toolbelt
*/

type __Either<O extends object, K extends Key> = Omit<O, K> &
{
// Merge all but K
[P in K]: Prisma__Pick<O, P & keyof O> // With K possibilities
}[K]

type EitherStrict<O extends object, K extends Key> = Strict<__Either<O, K>>

type EitherLoose<O extends object, K extends Key> = ComputeRaw<__Either<O, K>>

type _Either<
O extends object,
K extends Key,
strict extends Boolean
> = {
1: EitherStrict<O, K>
0: EitherLoose<O, K>
}[strict]

type Either<
O extends object,
K extends Key,
strict extends Boolean = 1
> = O extends unknown ? _Either<O, K, strict> : never

export type Union = any

type PatchUndefined<O extends object, O1 extends object> = {
[K in keyof O]: O[K] extends undefined ? At<O1, K> : O[K]
} & {}

/** Helper Types for "Merge" **/
export type IntersectOf<U extends Union> = (
U extends unknown ? (k: U) => void : never
Expand Down Expand Up @@ -16092,14 +16121,48 @@ export namespace Prisma {
gte?: number
not?: NestedFloatNullableFilter | number | null
}
export type JsonFilter =
| PatchUndefined<
Either<Required<JsonFilterBase>, Exclude<keyof Required<JsonFilterBase>, 'path'>>,
Required<JsonFilterBase>
>
| OptionalFlat<Omit<Required<JsonFilterBase>, 'path'>>

export type JsonFilter = {
export type JsonFilterBase = {
equals?: InputJsonValue
lt?: InputJsonValue
lte?: InputJsonValue
gt?: InputJsonValue
gte?: InputJsonValue
path?: Enumerable<string>
string_contains?: string
string_starts_with?: string
string_ends_with?: string
array_contains?: InputJsonValue
array_starts_with?: InputJsonValue
array_ends_with?: InputJsonValue
not?: InputJsonValue
}
export type JsonNullableFilter =
| PatchUndefined<
Either<Required<JsonNullableFilterBase>, Exclude<keyof Required<JsonNullableFilterBase>, 'path'>>,
Required<JsonNullableFilterBase>
>
| OptionalFlat<Omit<Required<JsonNullableFilterBase>, 'path'>>

export type JsonNullableFilter = {
export type JsonNullableFilterBase = {
equals?: InputJsonValue | null
lt?: InputJsonValue
lte?: InputJsonValue
gt?: InputJsonValue
gte?: InputJsonValue
path?: Enumerable<string>
string_contains?: string
string_starts_with?: string
string_ends_with?: string
array_contains?: InputJsonValue
array_starts_with?: InputJsonValue
array_ends_with?: InputJsonValue
not?: InputJsonValue | null
}

Expand Down Expand Up @@ -16259,9 +16322,26 @@ export namespace Prisma {
**/
max?: NestedFloatNullableFilter
}
export type JsonWithAggregatesFilter =
| PatchUndefined<
Either<Required<JsonWithAggregatesFilterBase>, Exclude<keyof Required<JsonWithAggregatesFilterBase>, 'path'>>,
Required<JsonWithAggregatesFilterBase>
>
| OptionalFlat<Omit<Required<JsonWithAggregatesFilterBase>, 'path'>>

export type JsonWithAggregatesFilter = {
export type JsonWithAggregatesFilterBase = {
equals?: InputJsonValue
lt?: InputJsonValue
lte?: InputJsonValue
gt?: InputJsonValue
gte?: InputJsonValue
path?: Enumerable<string>
string_contains?: string
string_starts_with?: string
string_ends_with?: string
array_contains?: InputJsonValue
array_starts_with?: InputJsonValue
array_ends_with?: InputJsonValue
not?: InputJsonValue
_count?: NestedIntFilter
/**
Expand All @@ -16282,9 +16362,26 @@ export namespace Prisma {
**/
max?: NestedJsonFilter
}
export type JsonNullableWithAggregatesFilter =
| PatchUndefined<
Either<Required<JsonNullableWithAggregatesFilterBase>, Exclude<keyof Required<JsonNullableWithAggregatesFilterBase>, 'path'>>,
Required<JsonNullableWithAggregatesFilterBase>
>
| OptionalFlat<Omit<Required<JsonNullableWithAggregatesFilterBase>, 'path'>>

export type JsonNullableWithAggregatesFilter = {
export type JsonNullableWithAggregatesFilterBase = {
equals?: InputJsonValue | null
lt?: InputJsonValue
lte?: InputJsonValue
gt?: InputJsonValue
gte?: InputJsonValue
path?: Enumerable<string>
string_contains?: string
string_starts_with?: string
string_ends_with?: string
array_contains?: InputJsonValue
array_starts_with?: InputJsonValue
array_ends_with?: InputJsonValue
not?: InputJsonValue | null
_count?: NestedIntNullableFilter
/**
Expand Down Expand Up @@ -17237,14 +17334,48 @@ export namespace Prisma {
**/
max?: NestedFloatNullableFilter
}
export type NestedJsonFilter =
| PatchUndefined<
Either<Required<NestedJsonFilterBase>, Exclude<keyof Required<NestedJsonFilterBase>, 'path'>>,
Required<NestedJsonFilterBase>
>
| OptionalFlat<Omit<Required<NestedJsonFilterBase>, 'path'>>

export type NestedJsonFilter = {
export type NestedJsonFilterBase = {
equals?: InputJsonValue
lt?: InputJsonValue
lte?: InputJsonValue
gt?: InputJsonValue
gte?: InputJsonValue
path?: Enumerable<string>
string_contains?: string
string_starts_with?: string
string_ends_with?: string
array_contains?: InputJsonValue
array_starts_with?: InputJsonValue
array_ends_with?: InputJsonValue
not?: InputJsonValue
}
export type NestedJsonNullableFilter =
| PatchUndefined<
Either<Required<NestedJsonNullableFilterBase>, Exclude<keyof Required<NestedJsonNullableFilterBase>, 'path'>>,
Required<NestedJsonNullableFilterBase>
>
| OptionalFlat<Omit<Required<NestedJsonNullableFilterBase>, 'path'>>

export type NestedJsonNullableFilter = {
export type NestedJsonNullableFilterBase = {
equals?: InputJsonValue | null
lt?: InputJsonValue
lte?: InputJsonValue
gt?: InputJsonValue
gte?: InputJsonValue
path?: Enumerable<string>
string_contains?: string
string_starts_with?: string
string_ends_with?: string
array_contains?: InputJsonValue
array_starts_with?: InputJsonValue
array_ends_with?: InputJsonValue
not?: InputJsonValue | null
}

Expand Down
@@ -1,6 +1,6 @@
generator client {
provider = "prisma-client-js"
previewFeatures = ["orderByRelation", "selectRelationCount"]
previewFeatures = ["orderByRelation", "selectRelationCount", "filterJson"]
}

datasource db {
Expand Down

0 comments on commit ef2bfe4

Please sign in to comment.