Skip to content

Commit

Permalink
chore: Use adapters from @prisma/* scope (#21156)
Browse files Browse the repository at this point in the history
  • Loading branch information
SevInf committed Sep 20, 2023
1 parent 5761e07 commit 6b26772
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 90 deletions.
2 changes: 1 addition & 1 deletion helpers/compile/plugins/tscPlugin.ts
Expand Up @@ -20,7 +20,7 @@ function bundleTypeDefinitions(filename: string, outfile: string) {
'decimal.js',
'detect-runtime',
'sql-template-tag',
'@jkomyno/prisma-driver-adapter-utils',
'@prisma/driver-adapter-utils',
'@opentelemetry/api',
'@prisma/internals',
'@prisma/generator-helper',
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Expand Up @@ -70,7 +70,6 @@
"@jest/create-cache-key-function": "29.7.0",
"@jest/globals": "29.7.0",
"@jest/test-sequencer": "29.7.0",
"@jkomyno/prisma-driver-adapter-utils": "0.3.0",
"@opentelemetry/api": "1.6.0",
"@opentelemetry/context-async-hooks": "1.17.0",
"@opentelemetry/instrumentation": "0.43.0",
Expand All @@ -86,6 +85,7 @@
"@prisma/internals": "workspace:*",
"@prisma/migrate": "workspace:*",
"@prisma/mini-proxy": "0.9.4",
"@prisma/driver-adapter-utils": "0.3.2",
"@snaplet/copycat": "0.16.0",
"@swc-node/register": "1.6.6",
"@swc/core": "1.3.75",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/runtime/core/engines/common/Engine.ts
@@ -1,4 +1,4 @@
import type { ErrorCapturingDriverAdapter } from '@jkomyno/prisma-driver-adapter-utils'
import type { ErrorCapturingDriverAdapter } from '@prisma/driver-adapter-utils'
import type { DataSource, GeneratorConfig } from '@prisma/generator-helper'
import { TracingHelper } from '@prisma/internals'

Expand Down
@@ -1,4 +1,4 @@
import type { ErrorCapturingDriverAdapter } from '@jkomyno/prisma-driver-adapter-utils'
import type { ErrorCapturingDriverAdapter } from '@prisma/driver-adapter-utils'

import type { QueryEngineConfig } from '../../common/types/QueryEngine'

Expand Down
@@ -1,5 +1,5 @@
import type { ErrorCapturingDriverAdapter } from '@jkomyno/prisma-driver-adapter-utils'
import Debug from '@prisma/debug'
import type { ErrorCapturingDriverAdapter } from '@prisma/driver-adapter-utils'
import { Sql } from 'sql-template-tag'

import { MiddlewareArgsMapper } from '../../getPrismaClient'
Expand Down
3 changes: 1 addition & 2 deletions packages/client/src/runtime/getPrismaClient.ts
@@ -1,7 +1,6 @@
import type { DriverAdapter } from '@jkomyno/prisma-driver-adapter-utils'
import { bindAdapter } from '@jkomyno/prisma-driver-adapter-utils'
import type { Context } from '@opentelemetry/api'
import Debug, { clearLogs } from '@prisma/debug'
import { bindAdapter, type DriverAdapter } from '@prisma/driver-adapter-utils'
import type { EnvValue, GeneratorConfig } from '@prisma/generator-helper'
import { ExtendedSpanOptions, logger, TracingHelper, tryLoadEnvs } from '@prisma/internals'
import type { LoadedEnv } from '@prisma/internals/dist/utils/tryLoadEnvs'
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/runtime/index.ts
Expand Up @@ -25,8 +25,8 @@ export { objectEnumValues } from './object-enums'
export { makeStrictEnum } from './strictEnum'
export type { DecimalJsLike } from './utils/decimalJsLike'
export { warnEnvConflicts } from './warnEnvConflicts'
export type { DriverAdapter } from '@jkomyno/prisma-driver-adapter-utils'
export { Debug } from '@prisma/debug'
export type { DriverAdapter } from '@prisma/driver-adapter-utils'
export { default as Decimal } from 'decimal.js'
export type { RawValue, Value } from 'sql-template-tag'
export { empty, join, raw, Sql, default as sqltag } from 'sql-template-tag'
Expand Down
22 changes: 11 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions reproductions/driver-adapters/package.json
Expand Up @@ -20,13 +20,13 @@
"author": "Alberto Schiabel <schiabel@prisma.io>",
"license": "ISC",
"dependencies": {
"@jkomyno/prisma-adapter-neon": "0.2.1",
"@jkomyno/prisma-adapter-pg": "0.2.1",
"@jkomyno/prisma-adapter-planetscale": "0.2.1",
"@jkomyno/prisma-driver-adapter-utils": "0.2.1",
"@neondatabase/serverless": "^0.6.0",
"@planetscale/database": "^1.11.0",
"@prisma/adapter-neon": "0.3.2",
"@prisma/adapter-pg": "0.3.2",
"@prisma/adapter-planetscale": "0.3.2",
"@prisma/client": "../../packages/client",
"@prisma/driver-adapter-utils": "0.3.2",
"pg": "^8.11.3",
"superjson": "^1.13.1",
"undici": "^5.22.1"
Expand Down
2 changes: 1 addition & 1 deletion reproductions/driver-adapters/src/neon.http.ts
@@ -1,5 +1,5 @@
import { neon } from '@neondatabase/serverless'
import { PrismaNeonHTTP } from '@jkomyno/prisma-adapter-neon'
import { PrismaNeonHTTP } from '@prisma/adapter-neon'
import { smokeTest } from './test'

async function main() {
Expand Down
4 changes: 2 additions & 2 deletions reproductions/driver-adapters/src/neon.ws.ts
@@ -1,5 +1,5 @@
import { Pool, neonConfig } from '@neondatabase/serverless'
import { PrismaNeon } from '@jkomyno/prisma-adapter-neon'
import { PrismaNeon } from '@prisma/adapter-neon'
import { WebSocket } from 'undici'
import { smokeTest } from './test'

Expand All @@ -8,7 +8,7 @@ neonConfig.webSocketConstructor = WebSocket
async function main() {
const connectionString = `${process.env.JS_NEON_DATABASE_URL as string}`

const pool = new Pool({
const pool = new Pool({
connectionString,
})
const adapter = new PrismaNeon(pool)
Expand Down
2 changes: 1 addition & 1 deletion reproductions/driver-adapters/src/pg.ts
@@ -1,5 +1,5 @@
import { Pool } from 'pg'
import { PrismaPg } from '@jkomyno/prisma-adapter-pg'
import { PrismaPg } from '@prisma/adapter-pg'
import { smokeTest } from './test'

async function main() {
Expand Down
4 changes: 2 additions & 2 deletions reproductions/driver-adapters/src/planetscale.ts
@@ -1,6 +1,6 @@
import { connect } from '@planetscale/database'
import { PrismaPlanetScale } from '@jkomyno/prisma-adapter-planetscale'
import { smokeTest } from './test'
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
import { smokeTest } from './test'

async function main() {
const connectionString = `${process.env.JS_PLANETSCALE_DATABASE_URL as string}`
Expand Down
121 changes: 60 additions & 61 deletions reproductions/driver-adapters/src/test.ts
@@ -1,7 +1,7 @@
import superjson from 'superjson'
import { PrismaClient } from '.prisma/client'
import { setImmediate, setTimeout } from 'node:timers/promises'
import type { DriverAdapter } from '@jkomyno/prisma-driver-adapter-utils'
import type { DriverAdapter } from '@prisma/driver-adapter-utils'

export async function smokeTest(adapter: DriverAdapter) {
// wait for the database pool to be initialized
Expand All @@ -15,7 +15,7 @@ export async function smokeTest(adapter: DriverAdapter) {
console.log('[nodejs] connected')

const test = new SmokeTest(prisma, adapter.flavour)

await test.testJSON()
await test.testTypeTest2()
await test.$raw()
Expand All @@ -40,7 +40,6 @@ export async function smokeTest(adapter: DriverAdapter) {
console.log('[nodejs] re-disconnected')
}


class SmokeTest {
constructor(private readonly prisma: PrismaClient, readonly flavour: DriverAdapter['flavour']) {}

Expand All @@ -56,7 +55,7 @@ class SmokeTest {
},
select: {
properties: true,
}
},
})

console.log('[nodejs] created', superjson.serialize(created).json)
Expand All @@ -77,23 +76,23 @@ class SmokeTest {
throw new Error('Abort the mission')
})
}

const two = async () => {
await setTimeout(500)
await this.prisma.leak_test.create({ data: {} })
}

await this.prisma.leak_test.deleteMany()
await Promise.allSettled([one(), two()])
}

async explicitTransaction() {
const [children, totalChildren] = await this.prisma.$transaction([
this.prisma.child.findMany(),
this.prisma.child.count(),
], {
isolationLevel: 'Serializable',
})
const [children, totalChildren] = await this.prisma.$transaction(
[this.prisma.child.findMany(), this.prisma.child.count()],
{
isolationLevel: 'Serializable',
},
)

console.log('[nodejs] children', superjson.serialize(children).json)
console.log('[nodejs] totalChildren', totalChildren)
Expand Down Expand Up @@ -123,7 +122,7 @@ class SmokeTest {
})
console.log('[nodejs] author', superjson.serialize(author).json)

const result = await this.prisma.$transaction(async tx => {
const result = await this.prisma.$transaction(async (tx) => {
await tx.author.deleteMany()
await tx.post.deleteMany()

Expand All @@ -141,7 +140,7 @@ class SmokeTest {
author: {
connect: {
id: author.id,
}
},
},
},
})
Expand Down Expand Up @@ -175,31 +174,31 @@ class SmokeTest {

const resultSet = await this.prisma.type_test.findMany({
select: {
'tinyint_column': true,
'smallint_column': true,
'mediumint_column': true,
'int_column': true,
'bigint_column': true,
'float_column': true,
'double_column': true,
'decimal_column': true,
'boolean_column': true,
'char_column': true,
'varchar_column': true,
'text_column': true,
'date_column': true,
'time_column': true,
'datetime_column': true,
'timestamp_column': true,
'json_column': true,
'enum_column': true,
'binary_column': true,
'varbinary_column': true,
'blob_column': true
}
tinyint_column: true,
smallint_column: true,
mediumint_column: true,
int_column: true,
bigint_column: true,
float_column: true,
double_column: true,
decimal_column: true,
boolean_column: true,
char_column: true,
varchar_column: true,
text_column: true,
date_column: true,
time_column: true,
datetime_column: true,
timestamp_column: true,
json_column: true,
enum_column: true,
binary_column: true,
varbinary_column: true,
blob_column: true,
},
})
console.log('[nodejs] findMany resultSet', superjson.serialize(resultSet).json)

return resultSet
}

Expand All @@ -210,26 +209,26 @@ class SmokeTest {

const resultSet = await this.prisma.type_test.findMany({
select: {
'smallint_column': true,
'int_column': true,
'bigint_column': true,
'float_column': true,
'double_column': true,
'decimal_column': true,
'boolean_column': true,
'char_column': true,
'varchar_column': true,
'text_column': true,
'date_column': true,
'time_column': true,
'datetime_column': true,
'timestamp_column': true,
'json_column': true,
'enum_column': true
}
smallint_column: true,
int_column: true,
bigint_column: true,
float_column: true,
double_column: true,
decimal_column: true,
boolean_column: true,
char_column: true,
varchar_column: true,
text_column: true,
date_column: true,
time_column: true,
datetime_column: true,
timestamp_column: true,
json_column: true,
enum_column: true,
},
})
console.log('[nodejs] findMany resultSet', superjson.serialize(resultSet).json)

return resultSet
}

Expand All @@ -238,9 +237,9 @@ class SmokeTest {

await this.prisma.child.deleteMany()
await this.prisma.parent.deleteMany()

/* Create a parent with some new children */

await this.prisma.child.create({
data: {
c: 'c1',
Expand All @@ -258,13 +257,13 @@ class SmokeTest {
id: '0001',
},
})

/* Delete the parent */

const resultDeleteMany = await this.prisma.parent.deleteMany({
where: {
p: 'p1'
}
p: 'p1',
},
})
console.log('[nodejs] resultDeleteMany', superjson.serialize(resultDeleteMany).json)
}
Expand Down

0 comments on commit 6b26772

Please sign in to comment.