Model discovery should populate `jsonSchema.maxLength` alongside `length` to support strict-mode validation

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

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
node.js, typescript
領域
backend, database

調査の方向性

Start by locating LoopBack's model discovery code and the tests for discovered string column metadata; the issue does not name specific files. Trace where the existing length property is populated and check how schema validation reads jsonSchema.maxLength. Update discovery so both values are represented, then verify tests cover overlong strings being rejected before database insertion.

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

説明

When discovering models from a database (e.g., MySQL), column length is represented by length property:

@property({
  type: 'string',
  length: 100,
})
name: string;

However, the validation layer does not evaluate the top-level length property. This causes issues depending on the database SQL mode:

Non-strict mode: Strings exceeding the limit are silently truncated by the database without any application-level error.

Strict mode: Instead of a clean validation error handled by LoopBack, the app will return an Internal Server Error.

Expected Behavior:

Model discovery should populate both the length property (for schema metadata) and set jsonSchema.maxLength for application-level validation (when the database is in strict mode). This allows LoopBack's schema validation to catch length violations and return proper validation errors before hitting a strict-mode database.

Proposed Solution:

Update model discovery to ensure that discovered string column lengths populate jsonSchema.maxLength while keeping the existing length property intact.

@property({
  type: 'string',
  jsonSchema: {
      maxLength: 100,
  },
  length: 100,
})
name: string;
主要言語
TypeScript
スター
5.1k
フォーク
1.1k
平均マージ
1日 19時間
マージ済み PR(30日)
47

環境構築

はじめの一歩

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

loopbackio/loopback-next のほかの issue

loopbackio/loopback-next の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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