Custom `sqltype=` for PK field with `Primary` isn't respected while TH parsing

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

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

評価

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

調査の方向性

Start in Database.Persist.TH.Internal and trace how the schema example is parsed into FieldDef for the SurrogateKey branch. Reproduce the failure with the persistent-mysql or persistent-mysql-haskell test suite and inspect the generated ItemSize migration. Done when the custom sqltype=varchar(80) is preserved for the primary-key field and the migration succeeds.

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

説明

I have recently discovered that test-suite of persistent-mysql-haskell (as well as persistent-mysql) is failing for the following schema:

share
    [mkPersist sqlSettings, mkMigrate "duplicateMigrate"]
    [persistUpperCase|
  Item
     name        Text sqltype=varchar(80)
     description Text
     price       Double Maybe
     quantity    Int Maybe

     Primary name
     deriving Eq Show Ord

  ItemSize
     Id          (Key Item) sqltype=varchar(80)
     size        Int
     deriving Eq Show Ord
|]

During tests while executing migration, it produces following script and error message:

CREATe TABLE `ItemSize`(`id` TEXT NOT NULL PRIMARY KEY,`size` BIGINT NOT NULL);
Migrating: CREATe TABLE `ItemSize`(`id` TEXT NOT NULL PRIMARY KEY,`size` BIGINT NOT NULL)
test: ConnectionError {errFunction = "query", errNumber = 1170, errMessage = "BLOB/TEXT column 'id' used in key specification without a key length"}
Test suite test: FAIL

Of course, migration script generator (with its CREATe) belongs to persistent-mysql, yet FieldDef of table columns is being parsed via persistent (core). And it turned out that custom sqltype is omitted there for SurrogateKey branch in Database.Persist.TH.Internal module.

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

環境構築

はじめの一歩

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

yesodweb/persistent のほかの issue

yesodweb/persistent の issue をすべて見る

似ている issue

Haskell の issue をもっと見る

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

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