Postgres enum types with an empty string as a valid value will break all parsing

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

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

  • #304 @wyf027 による — マージされずにクローズ

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
静か
技術スタック
postgresql, rust
領域
databases

調査の方向性

The issue describes a panic when queries return a PostgreSQL enum containing an empty string, but it does not identify a documentation file or specify where the limitation should be recorded. Read the existing documentation and decide whether this belongs in a FAQ or a known limitations section; done means documenting the behavior and a practical workaround clearly.

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

説明

bug parser

Migrated from halcyonnouveau/clorinde#92, originally reported by @KenAKAFrosty on 2025-04-16.

Not sure if this should even be considered a bug.

Possibly something to just mention in the docs or a FAQ.

If you have an enum type like CREATE TYPE badge AS ENUM ('staff', 'maintenance', 'guest', '') , where you have an empty string value as a valid part of the enum, expect to see this error when running the CLI if your queries return that column:

thread 'main' panicked at ...
Ident is not allowed to be empty; use Option<Ident>
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Makes sense when you consider that the created Rust enum can't (and shouldn't) support an empty value inherently

One could argue that the type shouldn't contain the empty value, but instead allow for nullable columns where that type is used. I'm inclined to agree, but I'm short on a time machine to convince my old self of that 😅

Not a huge deal as I can work around this now that I know the issue. But if someone was dipping their toes into clorinde, and hit this kind of error, it may put them off. Would be a shame since they wouldn't get to see how awesome clorinde is!

Happy to hear thoughts on this. And I'm open to help with getting it somewhere in the docs if that's something we want!


Original discussion

@beanpuppy (2025-04-17):

Thanks for bringing this up. Having an empty string value in an enum doesn't seem like a very good idea, so I wouldn't really want to add support for this even if we could.

I'm not sure if we need to document it anywhere as I doubt many people would do something like this. But since it is technically valid postgres to do this, and we aim to have complete postgres support for every possible thing it could do, I can see how we might want it documented somewhere just for completeness and posterity.

We don't have a FAQ, but I'm not opposed to the idea of it, I don't know what else could be added to it though.

We could also have a "known limitations" document for things like this. Although the only other thing I can think of right now to add to it is halcyonnouveau/clorinde#86, but there's probably more if I dug deeper and loosened my criteria for "limitation".

If it were just left to me, I'd probably leave it here and refer to this issue if anyone else comes and asks for it. But if you're really wanting to write some docs, you're free to open a PR with whatever you think is best.

主要言語
Rust
スター
1.2k
フォーク
77
平均マージ
5日 12時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

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

cornucopia-rs/cornucopia のほかの issue

cornucopia-rs/cornucopia の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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