Skip to content
Merged
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
63 changes: 63 additions & 0 deletions .changeset/swift-filters-shine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
'@opensaas/stack-cli': minor
---

Add full Prisma filter operator support to WhereInput types

The generated `WhereInput` types now expose all of Prisma's filter operators instead of just `equals` and `not`. This resolves GitHub issue #318.

**String fields** now support:

```typescript
const where: PostWhereInput = {
title: {
contains: 'search',
startsWith: 'Hello',
endsWith: '!',
in: ['Post 1', 'Post 2'],
notIn: ['Spam'],
mode: 'insensitive', // case-insensitive search
},
}
```

**Number fields** now support:

```typescript
const where: PostWhereInput = {
viewCount: {
gte: 100, // greater than or equal
lte: 1000, // less than or equal
gt: 50, // greater than
lt: 500, // less than
in: [10, 20, 30],
notIn: [0],
},
}
```

**DateTime fields** now support:

```typescript
const where: PostWhereInput = {
publishDate: {
gte: new Date('2024-01-01'),
lte: new Date('2024-12-31'),
},
}
```

**Boolean operators** now match Prisma's structure:

```typescript
const where: PostWhereInput = {
// AND can be single object OR array
AND: { status: { equals: 'published' } },
// OR is array-only
OR: [{ status: { in: ['published', 'draft'] } }, { title: { contains: 'important' } }],
// NOT can be single object OR array
NOT: { status: { equals: 'archived' } },
}
```

No migration required - this change is fully backward compatible. Existing code using `equals` and `not` will continue to work.
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,7 @@ export type UserUpdateInput = {
email?: string
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
email?: { equals?: string, not?: string }
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down
154 changes: 17 additions & 137 deletions packages/cli/src/generator/__snapshots__/types.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ export type UserUpdateInput = {
name?: string
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -252,14 +246,7 @@ export type PostUpdateInput = {
content?: string
}

export type PostWhereInput = {
id?: string
AND?: Array<PostWhereInput>
OR?: Array<PostWhereInput>
NOT?: PostWhereInput
title?: { equals?: string, not?: string }
content?: { equals?: string, not?: string }
}
export type PostWhereInput = Prisma.PostWhereInput

/**
* Hook types for Post list
Expand Down Expand Up @@ -462,18 +449,7 @@ export type UserUpdateInput = {
posts?: { connect: Array<{ id: string }>, disconnect: Array<{ id: string }> }
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
posts?: {
some?: PostWhereInput
every?: PostWhereInput
none?: PostWhereInput
}
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -701,14 +677,7 @@ export type PostUpdateInput = {
author?: { connect: { id: string } } | { disconnect: true }
}

export type PostWhereInput = {
id?: string
AND?: Array<PostWhereInput>
OR?: Array<PostWhereInput>
NOT?: PostWhereInput
title?: { equals?: string, not?: string }
author?: UserWhereInput
}
export type PostWhereInput = Prisma.PostWhereInput

/**
* Hook types for Post list
Expand Down Expand Up @@ -988,14 +957,7 @@ export type UserUpdateInput = {
lastName?: string
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
firstName?: { equals?: string, not?: string }
lastName?: { equals?: string, not?: string }
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -1231,14 +1193,7 @@ export type PostUpdateInput = {
content?: string
}

export type PostWhereInput = {
id?: string
AND?: Array<PostWhereInput>
OR?: Array<PostWhereInput>
NOT?: PostWhereInput
title?: { equals?: string, not?: string }
content?: { equals?: string, not?: string }
}
export type PostWhereInput = Prisma.PostWhereInput

/**
* Hook types for Post list
Expand Down Expand Up @@ -1438,13 +1393,7 @@ export type UserUpdateInput = {
name?: string
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -1647,14 +1596,7 @@ export type UserUpdateInput = {
email?: string
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
email?: { equals?: string, not?: string }
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -1854,13 +1796,7 @@ export type UserUpdateInput = {
name?: string
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -2001,13 +1937,7 @@ export type PostUpdateInput = {
title?: string
}

export type PostWhereInput = {
id?: string
AND?: Array<PostWhereInput>
OR?: Array<PostWhereInput>
NOT?: PostWhereInput
title?: { equals?: string, not?: string }
}
export type PostWhereInput = Prisma.PostWhereInput

/**
* Hook types for Post list
Expand Down Expand Up @@ -2148,13 +2078,7 @@ export type CommentUpdateInput = {
content?: string
}

export type CommentWhereInput = {
id?: string
AND?: Array<CommentWhereInput>
OR?: Array<CommentWhereInput>
NOT?: CommentWhereInput
content?: { equals?: string, not?: string }
}
export type CommentWhereInput = Prisma.CommentWhereInput

/**
* Hook types for Comment list
Expand Down Expand Up @@ -2394,14 +2318,7 @@ export type PostUpdateInput = {
author?: { connect: { id: string } } | { disconnect: true }
}

export type PostWhereInput = {
id?: string
AND?: Array<PostWhereInput>
OR?: Array<PostWhereInput>
NOT?: PostWhereInput
title?: { equals?: string, not?: string }
author?: UserWhereInput
}
export type PostWhereInput = Prisma.PostWhereInput

/**
* Hook types for Post list
Expand Down Expand Up @@ -2601,13 +2518,7 @@ export type UserUpdateInput = {
name?: string
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -2829,14 +2740,7 @@ export type PostUpdateInput = {
author?: { connect: { id: string } } | { disconnect: true }
}

export type PostWhereInput = {
id?: string
AND?: Array<PostWhereInput>
OR?: Array<PostWhereInput>
NOT?: PostWhereInput
title?: { equals?: string, not?: string }
author?: UserWhereInput
}
export type PostWhereInput = Prisma.PostWhereInput

/**
* Hook types for Post list
Expand Down Expand Up @@ -3036,13 +2940,7 @@ export type UserUpdateInput = {
name?: string
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -3263,18 +3161,7 @@ export type UserUpdateInput = {
posts?: { connect: Array<{ id: string }>, disconnect: Array<{ id: string }> }
}

export type UserWhereInput = {
id?: string
AND?: Array<UserWhereInput>
OR?: Array<UserWhereInput>
NOT?: UserWhereInput
name?: { equals?: string, not?: string }
posts?: {
some?: PostWhereInput
every?: PostWhereInput
none?: PostWhereInput
}
}
export type UserWhereInput = Prisma.UserWhereInput

/**
* Hook types for User list
Expand Down Expand Up @@ -3478,14 +3365,7 @@ export type PostUpdateInput = {
author?: { connect: { id: string } } | { disconnect: true }
}

export type PostWhereInput = {
id?: string
AND?: Array<PostWhereInput>
OR?: Array<PostWhereInput>
NOT?: PostWhereInput
title?: { equals?: string, not?: string }
author?: UserWhereInput
}
export type PostWhereInput = Prisma.PostWhereInput

/**
* Hook types for Post list
Expand Down
Loading
Loading