Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Datasource override from client constructor doesn't match the datasource block from the schema.prisma file #698

Closed
4 tasks
Jolg42 opened this issue May 19, 2020 · 2 comments
Labels
kind/improvement An improvement to existing feature and code. tech/engines Issue for tech Engines. tech/typescript Issue for tech TypeScript. topic: dx
Milestone

Comments

@Jolg42
Copy link
Member

Jolg42 commented May 19, 2020

Problem

prisma.schema

datasource myawesomedb {
  provider = "mysql"
  url      = "mysql://......"
}

The shape of the input in the constructor is not the same as the datasource block in the schema:

const client = new PrismaClient({
  datasources: {
    myawesomedb: 'mysql://........'
  },
})

Suggested solution

const client = new PrismaClient({
  datasources: {
    myawesomedb: {
      url: 'mysql://........',
    },
  },
})

Only the url can be overridden, this will add the provider as well.

Todo

  • Modify constructor
  • Add JSDoc
  • Update tests
  • Update docs
@Jolg42 Jolg42 added process/candidate Candidate for next Milestone. kind/improvement An improvement to existing feature and code. topic: dx labels May 19, 2020
@janpio janpio added tech/typescript Issue for tech TypeScript. tech/engines Issue for tech Engines. labels May 19, 2020
@janpio janpio added this to the Beta 7 milestone May 26, 2020
@janpio janpio removed the process/candidate Candidate for next Milestone. label May 26, 2020
@Jolg42
Copy link
Member Author

Jolg42 commented May 29, 2020

So I discussed with Tim and right now the most confusing part is that there is a bug in TypeScript and the autocompletion doesn’t work at all for this.

microsoft/TypeScript#37249

@janpio janpio modified the milestones: Beta 7, Beta 8 May 29, 2020
@timsuchanek
Copy link
Contributor

We now have fixed the auto-completion in the Prisma Client, so I would consider this "fixed" for now, because the confusion of what the input should be, should not occur anymore with the types.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/improvement An improvement to existing feature and code. tech/engines Issue for tech Engines. tech/typescript Issue for tech TypeScript. topic: dx
Projects
None yet
Development

No branches or pull requests

3 participants