Skip to content

Overwriting database connection string in Prisma Client does not work #2510

@janpio

Description

@janpio
datasource postgresql {
  provider = "postgresql"
  url      = "postgresql://..."
}

generator client {
  provider = "prisma-client-js"
}

model User {
  id      Int     @default(autoincrement()) @id
  email   String  @unique
  name    String?
  role    String?
  storeId Int?
}

model Product {
  id          Int     @default(autoincrement()) @id
  handle      String  @unique
  name        String?
  description String?
  price       Int?
}
const express = require('express')
const app = express() 
const port = process.env.PORT || 3000;

// const path = require('path')

const { PrismaClient } = require('@prisma/client')

const prismaPgPlain = new PrismaClient({
  log: ['query', 'info', 'warn'],
  datasources: {
    db: "asdfasdf",
  },
  //forceTransactions: true,
})

app.get('/api/pg-plain', async (req, res) => {
  const products = await prismaPgPlain.product.findMany({ first: 4 })
  res.send(JSON.stringify(products))
})

app.listen(port, () =>
  console.log(`Example app listening at http://localhost:${port}`),
)

This should not work as the database connection string is overwritten with asdfasdf - but it happily connects to the connection string from schema.prisma.

Metadata

Metadata

Assignees

Labels

bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.tech/enginesIssue for tech Engines.tech/typescriptIssue for tech TypeScript.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions