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
2 changes: 1 addition & 1 deletion .github/workflows/build-engine-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
fi

- name: Install Binaryen (includes wasm-opt)
uses: jaxxstorm/action-install-gh-release@v2
uses: jaxxstorm/action-install-gh-release@v2.1.0
with:
repo: WebAssembly/binaryen
tag: version_122
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('transforms IN template', () => {
type: 'templateSql',
fragments: [
{ type: 'stringChunk', chunk: 'SELECT * FROM users WHERE "userId" IN ' },
{ type: 'parameterTuple' },
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
{ type: 'stringChunk', chunk: ' OFFSET ' },
{ type: 'parameter' },
],
Expand Down Expand Up @@ -106,7 +106,7 @@ test('transforms IN template with empty list', () => {
type: 'templateSql',
fragments: [
{ type: 'stringChunk', chunk: 'SELECT * FROM users WHERE "userId" IN ' },
{ type: 'parameterTuple' },
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
{ type: 'stringChunk', chunk: ' OFFSET ' },
{ type: 'parameter' },
],
Expand Down Expand Up @@ -140,7 +140,7 @@ test('handles singleton list in IN template', () => {
type: 'templateSql',
fragments: [
{ type: 'stringChunk', chunk: 'SELECT * FROM users WHERE "userId" IN ' },
{ type: 'parameterTuple' },
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
{ type: 'stringChunk', chunk: ' OFFSET ' },
{ type: 'parameter' },
],
Expand Down Expand Up @@ -171,7 +171,7 @@ test('treats non-array element as a singleton list in IN template', () => {
type: 'templateSql',
fragments: [
{ type: 'stringChunk', chunk: 'SELECT * FROM users WHERE "userId" IN ' },
{ type: 'parameterTuple' },
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
{ type: 'stringChunk', chunk: ' OFFSET ' },
{ type: 'parameter' },
],
Expand Down Expand Up @@ -202,7 +202,7 @@ test("transforms IN template, doesn't touch scalar list", () => {
type: 'templateSql',
fragments: [
{ type: 'stringChunk', chunk: 'SELECT * FROM users WHERE "userId" IN ' },
{ type: 'parameterTuple' },
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
{ type: 'stringChunk', chunk: ' AND numbers = ' },
{ type: 'parameter' },
{ type: 'stringChunk', chunk: ' OFFSET ' },
Expand Down Expand Up @@ -406,7 +406,7 @@ test('chunking a SELECT..IN with a large parameterTuple', () => {
{ type: 'stringChunk', chunk: 'SELECT FROM "public"."User" WHERE "banned" = ' },
{ type: 'parameter' },
{ type: 'stringChunk', chunk: ' AND "id" IN ' },
{ type: 'parameterTuple' },
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
{ type: 'stringChunk', chunk: ' AND "name" = ' },
{ type: 'parameter' },
],
Expand Down Expand Up @@ -459,11 +459,9 @@ test('chunking a SELECT..IN with multiple parameterTuples', () => {
type: 'templateSql',
fragments: [
{ type: 'stringChunk', chunk: 'SELECT FROM "public"."User" WHERE "id" IN ' },
{
type: 'parameterTuple',
},
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
{ type: 'stringChunk', chunk: ' AND "age" IN ' },
{ type: 'parameterTuple' },
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
],
placeholderFormat: {
prefix: '$',
Expand Down Expand Up @@ -508,7 +506,7 @@ test('a SELECT..IN with a large parameterTuple that is not chunkable', () => {
{ type: 'stringChunk', chunk: 'SELECT FROM "public"."User" WHERE "banned" = ' },
{ type: 'parameter' },
{ type: 'stringChunk', chunk: ' AND "id" IN ' },
{ type: 'parameterTuple' },
{ type: 'parameterTuple', itemPrefix: '', itemSeparator: ',', itemSuffix: '' },
{ type: 'stringChunk', chunk: ' AND "name" = ' },
{ type: 'parameter' },
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ function renderFragment<Type extends DynamicArgType | undefined>(
const placeholders =
fragment.value.length == 0
? 'NULL'
: fragment.value.map(() => formatPlaceholder(placeholderFormat, ctx.placeholderNumber++)).join(',')
: fragment.value
.map(() => {
const item = formatPlaceholder(placeholderFormat, ctx.placeholderNumber++)
return `${fragment.itemPrefix}${item}${fragment.itemSuffix}`
})
.join(fragment.itemSeparator)
return `(${placeholders})`
}

Expand Down
7 changes: 6 additions & 1 deletion packages/client-engine-runtime/src/query-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export type DynamicArgType = ArgType | { arity: 'tuple'; elements: ArgType[] }
export type Fragment =
| { type: 'stringChunk'; chunk: string }
| { type: 'parameter' }
| { type: 'parameterTuple' }
| {
type: 'parameterTuple'
itemPrefix: string
itemSeparator: string
itemSuffix: string
}
| {
type: 'parameterTupleList'
itemPrefix: string
Expand Down
2 changes: 1 addition & 1 deletion packages/client-generator-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@prisma/client-common": "workspace:*",
"@prisma/debug": "workspace:*",
"@prisma/dmmf": "workspace:*",
"@prisma/engines-version": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/engines-version": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/fetch-engine": "workspace:*",
"@prisma/generator": "workspace:*",
"@prisma/get-platform": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/client-generator-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@prisma/client-common": "workspace:*",
"@prisma/debug": "workspace:*",
"@prisma/dmmf": "workspace:*",
"@prisma/engines-version": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/engines-version": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/fetch-engine": "workspace:*",
"@prisma/generator": "workspace:*",
"@prisma/get-platform": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"@prisma/dmmf": "workspace:*",
"@prisma/driver-adapter-utils": "workspace:*",
"@prisma/engines": "workspace:*",
"@prisma/engines-version": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/engines-version": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/fetch-engine": "workspace:*",
"@prisma/generator": "workspace:*",
"@prisma/generator-helper": "workspace:*",
Expand All @@ -210,7 +210,7 @@
"@prisma/migrate": "workspace:*",
"@prisma/param-graph": "workspace:*",
"@prisma/param-graph-builder": "workspace:*",
"@prisma/query-compiler-wasm": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/query-compiler-wasm": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/query-plan-executor": "workspace:*",
"@prisma/sqlcommenter": "workspace:*",
"@prisma/sqlcommenter-trace-context": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineMatrix } from '../../_utils/defineMatrix'
import { allProviders, Providers } from '../../_utils/providers'

export default defineMatrix(() => [
allProviders.filter(
({ provider }) => provider !== Providers.MYSQL && provider !== Providers.SQLITE && provider !== Providers.SQLSERVER,
),
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { idForProvider } from '../../../_utils/idForProvider'
import testMatrix from '../_matrix'

export default testMatrix.setupSchema(({ provider }) => {
return /* Prisma */ `
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "${provider}"
}

model Attachment {
id ${idForProvider(provider, { includeDefault: true })}
fileName String

@@index([fileName])
}
`
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import testMatrix from './_matrix'
// @ts-ignore
import type { PrismaClient } from './generated/prisma/client'

declare let prisma: PrismaClient

testMatrix.setupTestSuite(
() => {
afterEach(async () => {
await prisma.attachment.deleteMany()
})

test('correctly handles a case insensitive IN filter', async () => {
await prisma.attachment.createMany({
data: [{ fileName: 'abc.jpg' }, { fileName: 'DEF.txt' }, { fileName: 'ghi.png' }],
})

const results = await prisma.attachment.findMany({
where: {
fileName: {
in: ['AbC.jpg', 'DEF.txt'],
mode: 'insensitive',
},
},
select: {
id: true,
fileName: true,
},
})

expect(results).toHaveLength(2)
expect(results).toEqual(
expect.arrayContaining([
expect.objectContaining({ fileName: 'abc.jpg' }),
expect.objectContaining({ fileName: 'DEF.txt' }),
]),
)
})

test('correctly handles a case insensitive NOT IN filter', async () => {
await prisma.attachment.createMany({
data: [{ fileName: 'bcd.jpg' }, { fileName: 'efg.txt' }, { fileName: 'hij.png' }],
})
const results = await prisma.attachment.findMany({
where: {
fileName: {
notIn: ['BcD.jpg', 'efg.txt'],
mode: 'insensitive',
},
},
select: {
id: true,
fileName: true,
},
})

expect(results).toEqual([
expect.objectContaining({
fileName: 'hij.png',
}),
])
})
},
{
optOut: {
from: ['mysql', 'sqlite', 'sqlserver'],
reason: 'Case-insensitive filters are not supported in MySQL, SQLite, and SQL Server',
},
},
)
2 changes: 1 addition & 1 deletion packages/engines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"@prisma/debug": "workspace:*",
"@prisma/engines-version": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/engines-version": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/fetch-engine": "workspace:*",
"@prisma/get-platform": "workspace:*"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/fetch-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@prisma/debug": "workspace:*",
"@prisma/engines-version": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/engines-version": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/get-platform": "workspace:*"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
"@prisma/generator": "workspace:*",
"@prisma/generator-helper": "workspace:*",
"@prisma/get-platform": "workspace:*",
"@prisma/prisma-schema-wasm": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/schema-engine-wasm": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/prisma-schema-wasm": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/schema-engine-wasm": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/schema-files-loader": "workspace:*",
"arg": "5.0.2",
"prompts": "2.4.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@prisma/config": "workspace:*",
"@prisma/debug": "workspace:*",
"@prisma/driver-adapter-utils": "workspace:*",
"@prisma/engines-version": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/engines-version": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"@prisma/generator": "workspace:*",
"@prisma/get-platform": "workspace:*",
"@prisma/internals": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/schema-files-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"sideEffects": false,
"dependencies": {
"@prisma/prisma-schema-wasm": "7.5.0-7.e32e01e74d5841684e517d184a54aedc852ef795",
"@prisma/prisma-schema-wasm": "7.5.0-9.c6be8e68bf8e4a36534064f9323a343f2fcafe21",
"fs-extra": "11.3.0"
}
}
Loading
Loading