Skip to content

Unable to use Decimal @db.Money without including datasource in the partial schema file #79

@ricketyboo

Description

@ricketyboo

If I have a column type of Decimal @db.Money in one of the schemas I'm importing in my aurora.config.json to merge, I get a panic from rust

To Reproduce
Steps to reproduce the behavior:

  1. Create prisma/base.prisma with contents:
datasource db {
  provider = "postgres"
  url      = env("DATABASE_URL")
}
generator client {
  provider = "prisma-client-js"
}
  1. Create ./prisma/model.prisma with content:
model MyModel {
  id String @id @default(cuid())
  value Decimal @db.Money
}
  1. Create aurora.config.json with
  "files": [
    "./prisma/base.prisma",
    "./prisma/model.prisma"
  ],
  "output": "./prisma/schema.prisma"
}
  1. Run aurora
  2. See error
Error: Command failed with exit code 101: /mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x format
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: DatamodelError(InvalidNativeType { native_type: "Money", span: Span { start: 186, end: 210 } })', libs/datamodel/core/src/transform/ast_to_dml/lift.rs:484:26
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::result::unwrap_failed
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5
   3: datamodel::transform::ast_to_dml::lift::LiftAstToDml::lift_scalar_field_type
   4: datamodel::transform::ast_to_dml::lift::LiftAstToDml::lift
   5: datamodel::reformat::reformat
   6: prisma_fmt::format::run
   7: prisma_fmt::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    at makeError (/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async formatSchema (/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/dist/engine-commands/formatSchema.js:57:14) {
  shortMessage: 'Command failed with exit code 101: /mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x format',
  command: '/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x format',
  escapedCommand: '"/mnt/hdd/cloud/projects/code/apps/test-app/node_modules/@prisma/sdk/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x" format',
  exitCode: 101,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: 'thread \'main\' panicked at \'called `Result::unwrap()` on an `Err` value: DatamodelError(InvalidNativeType { native_type: "Money", span: Span { start: 186, end: 210 } })\', libs/datamodel/core/src/transform/ast_to_dml/lift.rs:484:26\n' +
    'stack backtrace:\n' +
    '   0: rust_begin_unwind\n' +
    '             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5\n' +
    '   1: core::panicking::panic_fmt\n' +
    '             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14\n' +
    '   2: core::result::unwrap_failed\n' +
    '             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5\n' +
    '   3: datamodel::transform::ast_to_dml::lift::LiftAstToDml::lift_scalar_field_type\n' +
    '   4: datamodel::transform::ast_to_dml::lift::LiftAstToDml::lift\n' +
    '   5: datamodel::reformat::reformat\n' +
    '   6: prisma_fmt::format::run\n' +
    '   7: prisma_fmt::main\n' +
    'note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
} Aurora could not parse the schema at ./prisma/model.prisma. Please ensure it is of a proper format.

Expected behavior
I expect the ./prisma/schema.prisma to be generated correctly

Desktop (please complete the following information):

  • OS: Linux
  • Version 5.16.12-arch1-1

tool version
"prisma-aurora": "^1.3.5",

Additional context
I can work around this by including a duplicate datasource db { provider = "postgres" url = env("DATABASE_URL") } into the second schema file, but it does mean I'm now having to declare this in every file that might be using this extended native type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions