Reflected NUMERIC columns lose their precision and scale

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

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

@olpa がすでに取り組んでいます。

2026年11月24日 から。

  • #341 @olpa による — オープン

評価

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

調査の方向性

Look at the reflection code in the dialect, likely in a file like dialect.py or reflection.py. The issue mentions reading from information_schema.columns; find where column types are constructed. You'll need to add reading of numeric_precision and numeric_scale when both are present. Test with a CrateDB instance to ensure the reflected column retains its precision and scale. Check for any existing tests for numeric column reflection.

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

説明

bug

When SQLAlchemy reflects a table, this dialect reads each column's type from information_schema.columns. It asks only for data_type, which holds the bare type name: numeric (and nothing else). The precision and scale sit in two other columns, numeric_precision and numeric_scale, which the dialect never reads. So the column comes back as a bare NUMERIC:

reflected NUMERIC(10, 2)   NUMERIC()

Two things go wrong because of it:

  1. The read value is correct, but its form changes slightly: SQLAlchemy formats it with the column's scale, and without one it falls back to ten decimal places.
read a stored 1.25         Decimal('1.2500000000')    # reads with default 10 precision
  1. Creating the column needs the precision, because crate refuses a NUMERIC column without one, so the dialect raises CompileError before sending the DDL.
CREATE TABLE from it       CompileError: CrateDB stores a NUMERIC column only with a precision, as in Numeric(precision=10, scale=2)

crate reports the precision today and that we could implement immediately (in theory), but the scale only comes with crate/crate#20275, which is planned for 6.4.6, so the dialect's reflection should read both (this ticket) only once it ships.

Also, it should only use them only when both are present.

An older server reports NUMERIC(10, 2) as precision 10 with a null scale, and reading that as NUMERIC(10) would drop the decimals of copied tables.

Arrays of NUMERIC report neither value even with that fix (see the example here => so reflected arrays stay without precision for now.

主要言語
Python
スター
9
フォーク
6
平均マージ
6日 13時間
マージ済み PR(30日)
8

環境構築

はじめの一歩

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

crate/sqlalchemy-cratedb のほかの issue

crate/sqlalchemy-cratedb の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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