Closed shiyuhang0 closed 8 months ago
TiDB Cloud serverless driver supports Unit8Array as input in v0.1.0. But it has a break change in v0.1.0:
Prisma Accept string and array for these types. Thus, conversion error occurs.
This PR fix this.
Test succeed locally
schema and codes:
generator client { provider = "prisma-client-js" previewFeatures = ["driverAdapters"] } datasource db { provider = "mysql" url = env("DATABASE_URL") } model user { id Int @id @default(autoincrement()) email String? @unique(map: "uniq_email") @db.VarChar(255) name String? @db.VarChar(255) bytes Bytes? } import { connect } from '@tidbcloud/serverless'; import { PrismaTiDBCloud } from '@tidbcloud/prisma-adapter'; import { PrismaClient } from '@prisma/client'; import dotenv from 'dotenv'; import { fetch } from 'undici' // setup dotenv.config(); const connectionString = "xxx"; const connection = connect({ url: connectionString ,fetch}); const adapter = new PrismaTiDBCloud(connection); const prisma = new PrismaClient({ adapter }); await prisma.user.deleteMany({}) // insert const user = await prisma.user.create({ data: { id: 1, email: 'test@prisma.io', name: 'test', bytes: Buffer.from('FSDF',"base64"), }, }) console.log(user)
result:
{ id: 1, email: 'test@prisma.io', name: 'test', bytes: <Buffer 15 20 c5> }
This PR format the whole codes
TiDB Cloud serverless driver supports Unit8Array as input in v0.1.0. But it has a break change in v0.1.0:
Prisma Accept string and array for these types. Thus, conversion error occurs.
This PR fix this.
Test
Test succeed locally
schema and codes:
result:
Other
This PR format the whole codes