From 7a1b44ba3ff8a8c4f820cb2c5c1a80f53fe61da1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 04:12:55 +0000 Subject: [PATCH] Fix DBAL Prisma adapter to handle undefined dialect and use SQLite adapter as fallback Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- .../src/adapters/prisma/context.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/dbal/development/src/adapters/prisma/context.ts b/dbal/development/src/adapters/prisma/context.ts index e07930d44..084ccd4b2 100644 --- a/dbal/development/src/adapters/prisma/context.ts +++ b/dbal/development/src/adapters/prisma/context.ts @@ -11,28 +11,24 @@ export function createPrismaContext( let prisma: PrismaClient - // For SQLite, we need to use the driver adapter - if (inferredDialect === 'sqlite') { - const dbPath = databaseUrl?.replace('file:', '') || '../../prisma/prisma/dev.db' + // For SQLite (or when dialect cannot be inferred), we need to use the driver adapter + if (inferredDialect === 'sqlite' || !databaseUrl || inferredDialect === undefined) { + const dbPath = databaseUrl?.replace('file:', '').replace('sqlite://', '') || '../../prisma/prisma/dev.db' const db = new Database(dbPath) // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const adapter = new PrismaBetterSqlite3(db) prisma = new PrismaClient({ adapter } as any) } else { - // For other databases, use the URL directly - prisma = new PrismaClient( - databaseUrl - ? { - datasources: { db: { url: databaseUrl } }, - } as any - : undefined - ) + // For PostgreSQL/MySQL with explicit connection strings + // Note: Prisma 7 removed datasources config, so this may not work + // Consider using adapters for all database types + throw new Error(`Prisma 7 requires adapters. Unsupported database dialect: ${inferredDialect}. Please use SQLite or implement adapters for other databases.`) } return { prisma, queryTimeout: options?.queryTimeout ?? 30000, - dialect: inferredDialect ?? 'generic' + dialect: inferredDialect ?? 'sqlite' } }