Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.datasources[0].provider from GetConfig needs to be a string and not a string[] #8467

Closed
Jolg42 opened this issue Jul 27, 2021 · 5 comments · Fixed by prisma/prisma-engines#2120 or #8556
Assignees
Labels
kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. team/schema Issue for team Schema. tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema tech/engines Issue for tech Engines.
Milestone

Comments

@Jolg42
Copy link
Member

Jolg42 commented Jul 27, 2021

Problem

const config = await getConfig({
	datamodel: schema,
})

// this `provider` value was a string before 2.22.0 but is now an array of string
config.datasources[0].provider

This is the related commit that introduced the regression:
prisma/prisma-engines@b096a80

In this commit it looks like we removed the array from the datasource but added it to the serialization.
Screen Shot 2021-07-27 at 16 40 35
Screen Shot 2021-07-27 at 16 40 11

Rust Type found in https://github.com/prisma/prisma-engines/blob/master/libs/datamodel/core/src/configuration/datasource.rs#L12-L13

    /// The provider string
    pub provider: String,

the tests also show it’s currently an array of strings with only one string https://github.com/prisma/prisma-engines/blob/master/libs/datamodel/core/tests/config/datasources.rs#L16

Suggestion

I think it should be a string and not an array returned here by the Rust code.

I could monkey patch in the CLI but it seems wrong because we have a datasource[] array and each datasource can only have one provider.
It looks like some legacy from the multi provider array feature deprecated a while ago.

Internal Slack Thread here

@Jolg42 Jolg42 added kind/regression A reported bug in functionality that used to work before. process/candidate tech/engines Issue for tech Engines. tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema team/schema Issue for team Schema. team/client Issue for team Client. labels Jul 27, 2021
@Jolg42 Jolg42 changed the title config.datasources[0].provider from GetConfig needs to be a string and not a string[] config.datasources[0].provider from GetConfig needs to be a string and not a string[] Jul 27, 2021
@thebiglabasky thebiglabasky added this to the 2.29.0 milestone Jul 28, 2021
@thebiglabasky thebiglabasky assigned Jolg42 and unassigned do4gr Jul 28, 2021
@thebiglabasky
Copy link

We'll for now research places where this fix on getConfig would have an impact to ensure we don't break unexpectedly shortly before releasing.
Next step is to share the outcome of the research here before deciding how to fix this.
People to speak to: @madebysid (Studio), @millsp and/or @williamluke4

@sdnts
Copy link
Contributor

sdnts commented Jul 28, 2021

Studio doesn't use getConfig directly anymore, so we're good there. If the getGenerators function behaves the same as before, Studio will not need any changes.

@Jolg42
Copy link
Member Author

Jolg42 commented Aug 3, 2021

Found these lines using it, we can easily fix them after the engine fix:

Tried the hacky patch on TS side and can confirm it works.

@pimeys
Copy link
Contributor

pimeys commented Aug 3, 2021

Reopening, so @Jolg42 can close it if nothing breaks in the clients.

@Jolg42
Copy link
Member Author

Jolg42 commented Aug 4, 2021

Closing, small changes were made in #8556 which then made it through our dev pipeline in 2.29.0-dev.24

Thanks! 💚

@Jolg42 Jolg42 closed this as completed Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. team/schema Issue for team Schema. tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema tech/engines Issue for tech Engines.
Projects
None yet
6 participants