-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca9d6cc
commit b06ff9e
Showing
39 changed files
with
1,541 additions
and
226 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
enum QueryGet { | ||
Pk(String), | ||
Dk(String, String), | ||
Gk(String), | ||
} | ||
|
||
enum QueryIter { | ||
Pk(String), | ||
Dk(String), | ||
Gk(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
extern crate proc_macro; | ||
|
||
mod model_attributes; | ||
mod model_struct_db; | ||
mod struct_db; | ||
|
||
use proc_macro::TokenStream; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::collections::HashSet; | ||
use syn::meta::ParseNestedMeta; | ||
use syn::parse::Result; | ||
use syn::Ident; | ||
|
||
#[derive(Default, Clone)] | ||
pub(crate) struct ModelAttributes { | ||
pk_function_name: Option<Ident>, // Primary Key Function Name | ||
gk_function_names: HashSet<Ident>, // Generic Secondary Key Function Names // gk ou gsk | ||
// TODO: Derived Secondary Key Function Names: dk ou dsk | ||
} | ||
|
||
impl ModelAttributes { | ||
pub(crate) fn pk(&self) -> Ident { | ||
self.pk_function_name.clone().expect("pk is required") | ||
} | ||
|
||
pub(crate) fn pk_name(&self) -> String { | ||
self.pk().to_string().to_lowercase() | ||
} | ||
|
||
pub(crate) fn gk_function_names(&self) -> HashSet<Ident> { | ||
self.gk_function_names.clone() | ||
} | ||
|
||
pub(crate) fn parse(&mut self, meta: ParseNestedMeta) -> Result<()> { | ||
if meta.path.is_ident("pk") { | ||
self.pk_function_name = Some(meta.value()?.parse()?); | ||
} else if meta.path.is_ident("gk") { | ||
self.gk_function_names.insert(meta.value()?.parse()?); | ||
} else { | ||
panic!( | ||
"Unknown attribute: {}", | ||
meta.path.get_ident().unwrap().to_string() | ||
); | ||
} | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.