From d97f7fe02a5d298b737c312706ac584a401ced72 Mon Sep 17 00:00:00 2001 From: Eric Ridge Date: Sat, 16 Dec 2023 14:36:39 -0500 Subject: [PATCH] fix issue #1437 (#1440) This fixes issue #1437. The problem here is that we were blindly converting the entire `syn::Variant` value to the Postgres enum variant name when in fact all we want is its `Ident` value. --- pgrx-sql-entity-graph/src/postgres_enum/mod.rs | 2 +- pgrx-tests/src/tests/enum_type_tests.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pgrx-sql-entity-graph/src/postgres_enum/mod.rs b/pgrx-sql-entity-graph/src/postgres_enum/mod.rs index 96e6f68f4..c1cbed915 100644 --- a/pgrx-sql-entity-graph/src/postgres_enum/mod.rs +++ b/pgrx-sql-entity-graph/src/postgres_enum/mod.rs @@ -121,7 +121,7 @@ impl ToEntityGraphTokens for PostgresEnum { let (_static_impl_generics, static_ty_generics, static_where_clauses) = static_generics.split_for_impl(); - let variants = self.variants.iter(); + let variants = self.variants.iter().map(|variant| variant.ident.clone()); let sql_graph_entity_fn_name = syn::Ident::new(&format!("__pgrx_internals_enum_{}", name), Span::call_site()); diff --git a/pgrx-tests/src/tests/enum_type_tests.rs b/pgrx-tests/src/tests/enum_type_tests.rs index 87e1577f6..143797527 100644 --- a/pgrx-tests/src/tests/enum_type_tests.rs +++ b/pgrx-tests/src/tests/enum_type_tests.rs @@ -9,8 +9,9 @@ //LICENSE Use of this source code is governed by the MIT license that can be found in the LICENSE file. use pgrx::prelude::*; -#[derive(PostgresEnum, PartialEq, Debug)] +#[derive(PostgresEnum, PartialEq, Debug, Default)] pub enum Foo { + #[default] One, Two, Three,