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

Error using totvs database: Couldn\'t parse default value #5423

Closed
jaimersoncabral opened this issue Feb 2, 2021 · 6 comments · Fixed by prisma/prisma-engines#1669
Closed
Assignees
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines/migration engine Issue in the Migration Engine topic: migrate
Milestone

Comments

@jaimersoncabral
Copy link

Hi Prisma Team! Prisma Migrate just crashed.

Versions

Name Version
Platform debian-openssl-1.1.x
Node v14.15.4
Prisma CLI 2.15.0
Binary e51dc3b5a9ee790a07104bec1c9477d51740fe54

Error

Error: [libs/sql-schema-describer/src/mssql.rs:264:30] called `Result::unwrap()` on an `Err` value: "Couldn\'t parse default value: `CREATE DEFAULT DEF_DLOGICONULL AS 0\r\n`"
@Jolg42
Copy link
Member

Jolg42 commented Feb 2, 2021

Hi @jaimersoncabral

Could you add your schema?

Also which command did you run?

@Jolg42 Jolg42 added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. tech/engines/migration engine Issue in the Migration Engine kind/bug A reported bug. team/schema Issue for team Schema. topic: migrate labels Feb 2, 2021
@Jolg42 Jolg42 changed the title Error using totvs database Error using totvs database: Couldn\'t parse default value Feb 2, 2021
@tomhoule
Copy link
Contributor

note: should be @default(dbgenerated("..."))

@albertoperdomo albertoperdomo added this to the 2.18.0 milestone Feb 17, 2021
@pimeys
Copy link
Contributor

pimeys commented Feb 19, 2021

Looking into this today.

@pimeys
Copy link
Contributor

pimeys commented Feb 19, 2021

I can replicate the bug. There seems to be another way of setting default values in SQL Server. Typically, we create defaults like this:

CREATE TABLE cats (
    id INT IDENTITY PRIMARY KEY,
    name NVARCHAR(255) CONSTRAINT DF_cat_name DEFAULT 'musti'
);

There is another way of creating default values too in SQL Server, you can define them beforehand, and use a stored procedure to set them to a column:

CREATE DEFAULT catcat AS 'musti';

CREATE TABLE cats (
    id INT IDENTITY PRIMARY KEY,
    name NVARCHAR(255)
);

sp_bindefault 'catcat', 'dbo.cats.name';

So, this kind of makes our migrations a bit problematic. We'd like to have the default values in the data model, and then point to them from the column declaration to get the correct result. I need to discuss this a bit with the team, if we could find a nice and easy solution, or will this stretch to a complete new feature.

@pimeys
Copy link
Contributor

pimeys commented Feb 19, 2021

Our decision for now is to ignore the default values during introspection for these fields. This means, that in the data model the field will not have @default attribute. If you later on want to change the default value in the data model, the migration needs to be done manually to the database.

We might introduce something to represent this kind of default values later on, but I wouldn't expect it that quickly.

@pimeys
Copy link
Contributor

pimeys commented Feb 24, 2021

Documentation change for this: prisma/docs#1348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines/migration engine Issue in the Migration Engine topic: migrate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants