Consider Removing New Line Characters when Comparing Computed Constructs

オープン 初心者向け
#1,121 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

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

調査の方向性

データベースとローカルの計算済み句が比較前にサニタイズされる alembic/autogenerate/compare.py の1047~1055行目付近から始めます。PostgreSQL に対して複数行の Computed Column で問題を再現し、その後、改行位置が異なる同等の句で computed-default warning が発生しなくなることを確認します。

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

説明

autogenerate - detection bug

I'm working with a Computed Column construct, which is really long and therefore contains line breaks for readability.

When this construct gets imported into the underlying database (Postgres in my case), the construct gets reformatted with line breaks inserted in different places.

This creates a small side-effect, where alembic now thinks that the original computed clause provided by the migration file is different to the one in the database, and therefore emits a warning.

/usr/local/lib/python3.10/site-packages/alembic/autogenerate/compare.py:1090: 
UserWarning: Computed default on ***  cannot be modified
util.warn("Computed default on %s.%s cannot be modified" % (tname, cname))

After inspecting the code, I found this method, which appears to sanitize the database computed clause as well as the local one:

https://github.com/sqlalchemy/alembic/blob/fc451e60731ad5b8d73255f0a1996e1d4e0f20de/alembic/autogenerate/compare.py#L1047-L1055

I feel that we should include line breaks in the list of tokens that should be removed before a comparison takes place, but happy to hear what thoughts you have on this.

Thanks!

主要言語
Python
スター
4.5k
フォーク
391
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

sqlalchemy/alembic のほかの issue

sqlalchemy/alembic の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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