postgres({ config }) resolves from the working directory, but the guide says relative to the module file

オープン
#469 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend, databases

調査の方向性

Read packages/1-prisma-cloud/1-extensions/target/src/orm-postgres.ts, then trace how config reaches resolveOrmConfig in packages/1-prisma-cloud/1-extensions/target/src/descriptors/orm-postgres.ts and loadConfig in packages/1-prisma-cloud/1-extensions/target/src/orm-config.ts. Compare that path handling with the guide and ADR-0004; the issue is resolved when module-relative behavior matches the documented rule or the guide is corrected. The report was inferred from source and was not reproduced.

索引モデルが issue の本文から書いたものです。

説明

Composer 0.40.0, prisma/orm 8.0.0-rc.25.

Inferred from source at v0.40.0; not reproduced.

  • The guide promises module-relative resolution: docs/guides/building-an-app.md lines 240-243, "naming the prisma.config.ts path (relative to the module file) so the deploy can reload the emitted contract.json and find migrations/". ADR-0004 ("paths resolve relative to the authoring file") states the same rule for authoring paths in general.
  • The code does not: PostgresResourceNode keeps config as given (packages/1-prisma-cloud/1-extensions/target/src/orm-postgres.ts). The lowering passes it unchanged, resolveOrmConfig(node.config) (packages/1-prisma-cloud/1-extensions/target/src/descriptors/orm-postgres.ts line 43), which calls loadConfig(configPath) with no cwd (packages/1-prisma-cloud/1-extensions/target/src/orm-config.ts line 51). The ORM resolves a relative path against process.cwd(): const cwd = options?.cwd ?? process.cwd(); const resolvedConfigPath = configPath ? resolve(cwd, configPath) : undefined; (prisma/orm v8.0.0-rc.25, packages/1-framework/3-tooling/config-loader/src/load.ts lines 276-277). prisma dev and prisma deploy converge with the working directory set to where the command ran (packages/0-framework/3-tooling/cli/src/operations/execute-dev.ts line 305, the DEV.WORKER_THREAD explanation; packages/0-framework/3-tooling/cli/src/converge-process.ts).
  • Composer's own nested example steps around it: examples/store/modules/catalog/src/module.ts line 20 builds an absolute path, const config = fileURLToPath(new URL('../prisma.config.ts', import.meta.url));.
  • Effect: a module in a subdirectory that passes config: './prisma.config.ts', meaning the file beside the module as the guide says, gets the prisma.config.ts in the directory the command runs from instead. A root module.ts beside prisma.config.ts, run from that directory, works under both readings.
  • Expected: config resolves relative to the file that calls postgres(), as the guide and ADR-0004 say, or the guide says otherwise.

Found while writing the Composer docs on prisma.io (prisma/web#8965). The docs do not work around this.

主要言語
TypeScript
スター
6
フォーク
2
平均マージ
1日 2時間
マージ済み PR(30日)
33

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

prisma/composer のほかの issue

prisma/composer の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。