Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(client): Remove
mappings
from base dmmf (#18828)
* perf(client): Remove `mappings` from base dmmf Fix prisma/client-planning#320 * Better error for graphql action * Add test for unsupported action * Skip test on edge client
- Loading branch information
Showing
13 changed files
with
124 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/client/src/runtime/core/protocol/json/JsonProtocolEncoder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/client/tests/functional/unsupported-action/_matrix.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineMatrix } from '../_utils/defineMatrix' | ||
|
||
export default defineMatrix(() => [ | ||
[ | ||
{ | ||
provider: 'sqlite', | ||
}, | ||
{ | ||
provider: 'postgresql', | ||
}, | ||
{ | ||
provider: 'mysql', | ||
}, | ||
{ | ||
provider: 'cockroachdb', | ||
}, | ||
{ | ||
provider: 'sqlserver', | ||
}, | ||
], | ||
]) |
19 changes: 19 additions & 0 deletions
19
packages/client/tests/functional/unsupported-action/prisma/_schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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}" | ||
url = env("DATABASE_URI_${provider}") | ||
} | ||
model User { | ||
id ${idForProvider(provider)} | ||
} | ||
` | ||
}) |
53 changes: 53 additions & 0 deletions
53
packages/client/tests/functional/unsupported-action/tests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { getQueryEngineProtocol } from '@prisma/internals' | ||
|
||
import testMatrix from './_matrix' | ||
// @ts-ignore | ||
import type { PrismaClient } from './node_modules/@prisma/client' | ||
|
||
declare let prisma: PrismaClient | ||
|
||
testMatrix.setupTestSuite( | ||
() => { | ||
testIf(getQueryEngineProtocol() === 'graphql')('unsupported method (graphql)', async () => { | ||
// @ts-expect-error | ||
const result = prisma.user.aggregateRaw() | ||
await expect(result).rejects.toMatchPrismaErrorInlineSnapshot(` | ||
Invalid \`prisma.user.aggregateRaw()\` invocation in | ||
/client/tests/functional/unsupported-action/tests.ts:0:0 | ||
XX () => { | ||
XX testIf(getQueryEngineProtocol() === 'graphql')('unsupported method (graphql)', async () => { | ||
XX // @ts-expect-error | ||
→ XX const result = prisma.user.aggregateRaw( | ||
Model \`User\` does not support \`aggregateRaw\` action. | ||
`) | ||
}) | ||
|
||
testIf(getQueryEngineProtocol() === 'json')('unsupported method (json)', async () => { | ||
// @ts-expect-error | ||
const result = prisma.user.aggregateRaw() | ||
await expect(result).rejects.toMatchPrismaErrorInlineSnapshot(` | ||
Invalid \`prisma.user.aggregateRaw()\` invocation in | ||
/client/tests/functional/unsupported-action/tests.ts:0:0 | ||
XX | ||
XX testIf(getQueryEngineProtocol() === 'json')('unsupported method (json)', async () => { | ||
XX // @ts-expect-error | ||
→ XX const result = prisma.user.aggregateRaw( | ||
Operation 'aggregateRaw' for model 'User' does not match any query. | ||
`) | ||
}) | ||
}, | ||
{ | ||
skipDataProxy: { | ||
runtimes: ['edge'], | ||
reason: 'Error rendering is different for edge client', | ||
}, | ||
optOut: { | ||
from: ['mongodb'], | ||
reason: 'Test uses aggregateRaw as an example of unsupported method for SQL databases, it exists on mongo', | ||
}, | ||
}, | ||
) |