Skip to content

Commit

Permalink
Escape rust keyword when generating conjunct relation impl
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 authored and andy128k committed Sep 25, 2022
1 parent 4286c58 commit 0fb8604
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sea-orm-codegen/src/entity/conjunct_relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 0fb8604

Please sign in to comment.