From 30b8fe4e9bf1aa22b0ebc7458ca01ef794e644be Mon Sep 17 00:00:00 2001 From: Kira Sotnikov Date: Wed, 19 Mar 2025 09:26:37 +0300 Subject: [PATCH] Fix Available Type Enum filter for unique types --- codegen/src/worktable/generator/queries/type.rs | 7 ++++++- examples/src/main.rs | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/codegen/src/worktable/generator/queries/type.rs b/codegen/src/worktable/generator/queries/type.rs index ce099160..f5d73469 100644 --- a/codegen/src/worktable/generator/queries/type.rs +++ b/codegen/src/worktable/generator/queries/type.rs @@ -9,11 +9,16 @@ impl Generator { let name_generator = WorktableNameGenerator::from_table_name(self.name.to_string()); let avt_type_ident = name_generator.get_available_type_ident(); - let rows: Vec<_> = self + let unique_types: std::collections::HashSet = self .columns .indexes .iter() .filter_map(|(_, idx)| self.columns.columns_map.get(&idx.field)) + .map(|ty| ty.to_string()) + .collect(); + + let rows: Vec<_> = unique_types + .iter() .map(|s| { let type_ident = Ident::new(s.to_string().as_str(), Span::mixed_site()); let type_upper = diff --git a/examples/src/main.rs b/examples/src/main.rs index 21df479b..21a6115b 100644 --- a/examples/src/main.rs +++ b/examples/src/main.rs @@ -13,11 +13,13 @@ fn main() { attr: String, attr2: i16, attr_float: f64, + attr_string: String, }, indexes: { idx1: attr, idx2: attr2, + idx3: attr_string, }, queries: { update: { @@ -43,6 +45,7 @@ fn main() { test: 1, id: 0, attr_float: 100.0, + attr_string: "String_attr".to_string(), }; // insert