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

Aperta
#289 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

  • #304 di @wyf027 — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
postgresql, rust
Ambito
databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
1.2k
Fork
77
Merge medio
5g 12h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cornucopia-rs/cornucopia

Tutte le issue di cornucopia-rs/cornucopia

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.