From 73e46b7d5b0231a6462800c0747a49bb69349da6 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Tue, 20 Sep 2022 12:42:39 +0800 Subject: [PATCH] Escape rust keyword when generating conjunct relation impl --- sea-orm-codegen/src/entity/conjunct_relation.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sea-orm-codegen/src/entity/conjunct_relation.rs b/sea-orm-codegen/src/entity/conjunct_relation.rs index 05e8010a7..a156cf77a 100644 --- a/sea-orm-codegen/src/entity/conjunct_relation.rs +++ b/sea-orm-codegen/src/entity/conjunct_relation.rs @@ -2,6 +2,8 @@ use heck::{CamelCase, SnakeCase}; use proc_macro2::Ident; use quote::format_ident; +use crate::util::escape_rust_keyword; + #[derive(Clone, Debug)] pub struct ConjunctRelation { pub(crate) via: String, @@ -10,11 +12,11 @@ pub struct ConjunctRelation { impl ConjunctRelation { pub fn get_via_snake_case(&self) -> Ident { - format_ident!("{}", self.via.to_snake_case()) + format_ident!("{}", escape_rust_keyword(self.via.to_snake_case())) } pub fn get_to_snake_case(&self) -> Ident { - format_ident!("{}", self.to.to_snake_case()) + format_ident!("{}", escape_rust_keyword(self.to.to_snake_case())) } pub fn get_to_camel_case(&self) -> Ident {