Skip to content

Default Value of False Fails Contract Validation #951

Description

@dylan-cancelliere

Package and version

@prisma-next/postgres@0.14.0

What happened?

Having a default value of a boolean column of false generates an incorrect contract artifcat (via prisma-next contract emit), which subsequently fails validation (via prisma-next migration plan).

What did you expect to happen?

it seems like in the generated contract.json there's a missing "value" field when comparing to the output with a default value of true (which does validate successfully).

Incorrect output, editied for clarity:

"foo": {
  "columns": {
    "bar": {
      "default": {
        "kind": "literal"
      },
    }
  },
},

Correct output:

"foo": {
  "columns": {
    "bar": {
      "default": {
        "kind": "literal",
        "value": true    // Here
      },
    }
  },
}

Minimal reproduction

contract.prisma:

model Foo {
  bar Boolean @default(false)
}

contract.json:

{
  "schemaVersion": "1",
  "targetFamily": "sql",
  "target": "postgres",
  "profileHash": <redacted>,
  "roots": {
    "foo": {
      "model": "Foo",
      "namespace": "public"
    }
  },
  "domain": {
    "namespaces": {
      "public": {
        "models": {
          "Foo": {
            "fields": {
              "bar": {
                "nullable": false,
                "type": {
                  "codecId": "pg/bool@1",
                  "kind": "scalar"
                }
              }
            },
            "relations": {},
            "storage": {
              "fields": {
                "bar": {
                  "column": "bar"
                }
              },
              "namespaceId": "public",
              "table": "foo"
            }
          }
        }
      }
    }
  },
  "storage": {
    "namespaces": {
      "public": {
        "entries": {
          "table": {
            "foo": {
              "columns": {
                "bar": {
                  "codecId": "pg/bool@1",
                  "default": {
                    "kind": "literal"
                  },
                  "nativeType": "bool",
                  "nullable": false
                }
              },
              "foreignKeys": [],
              "indexes": [],
              "uniques": []
            }
          }
        },
        "id": "public",
        "kind": "postgres-schema"
      }
    },
    "storageHash": <redacted>
  },
  "capabilities": {
    "postgres": {
      "distinctOn": true,
      "jsonAgg": true,
      "lateral": true,
      "limit": true,
      "orderBy": true,
      "returning": true
    },
    "sql": {
      "defaultInInsert": true,
      "enums": true,
      "lateral": true,
      "returning": true
    }
  },
  "extensionPacks": {},
  "meta": {},
  "_generated": {
    "warning": "⚠️  GENERATED FILE - DO NOT EDIT",
    "message": "This file is automatically generated by \"prisma-next contract emit\".",
    "regenerate": "To regenerate, run: prisma-next contract emit"
  }
}

Environment

node: v24.14.1
os: macOs 26.5.1
pnpm: 10.16.1
PostgreSQL 17.2

Additional context

Encountered this my first time trying Prisma, apologies if it's dumb user error 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageAwaiting maintainer triage

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions