Skip to content

Commit

Permalink
reduce dep tree
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtbuilds committed Jan 4, 2025
1 parent 84454a8 commit 14c44a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ sqlmo = "0.22.7"
sqlx = "0.8.2"
sqlx-core = "0.8.2"
syn = "2.0.94"
ormlite-core = { path = "core", version="0.22" }
ormlite-attr = { path = "attr", version="0.22" }
ormlite-macro = { path = "macro", version="0.22" }
ormlite = { path = "ormlite", version="0.22" }
ormlite-core = { path = "core", version = "0.22" }
ormlite-attr = { path = "attr", version = "0.22" }
ormlite-macro = { path = "macro", version = "0.22" }
ormlite = { path = "ormlite", version = "0.22" }
convert_case = "0.6"
2 changes: 1 addition & 1 deletion attr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2", features = ["full"] }
structmeta = "0.3.0"
convert_case = "0.6"
convert_case.workspace = true
anyhow = "1.0"
ignore = "0.4"
sqlmo = "0.22"
Expand Down
4 changes: 1 addition & 3 deletions macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ proc-macro2 = "1"
ormlite-core.workspace = true
ormlite-attr.workspace = true
sqlx.workspace = true
lazy_static = "1"
once_cell = "1"
itertools = "0.13.0"
heck = "0.5"
convert_case.workspace = true
12 changes: 8 additions & 4 deletions macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
#![allow(non_snake_case)]

use codegen::insert::impl_Insert;
use heck::ToSnakeCase;
use convert_case::{Case, Casing};
use ormlite_attr::InsertMeta;
use proc_macro::TokenStream;
use std::borrow::Borrow;
use std::cell::OnceCell;
use std::collections::HashMap;
use std::env;
use std::env::var;
use std::ops::Deref;
use std::sync::OnceLock;
use syn::DataEnum;

use once_cell::sync::OnceCell;
use quote::quote;
use syn::{parse_macro_input, Data, DeriveInput};

Expand All @@ -38,7 +39,7 @@ mod util;
/// Mapping from StructName -> ModelMeta
pub(crate) type MetadataCache = HashMap<String, ModelMeta>;

static TABLES: OnceCell<MetadataCache> = OnceCell::new();
static TABLES: OnceLock<MetadataCache> = OnceLock::new();

fn get_tables() -> &'static MetadataCache {
TABLES.get_or_init(|| load_metadata_cache())
Expand Down Expand Up @@ -266,7 +267,10 @@ pub fn derive_ormlite_enum(input: TokenStream) -> TokenStream {

// Collect variant names and strings into vectors
let variant_names: Vec<_> = variants.iter().map(|v| &v.ident).collect();
let variant_strings: Vec<_> = variant_names.iter().map(|v| v.to_string().to_snake_case()).collect();
let variant_strings: Vec<_> = variant_names
.iter()
.map(|v| v.to_string().to_case(Case::Snake))
.collect();

let gen = quote! {
impl std::fmt::Display for #enum_name {
Expand Down

0 comments on commit 14c44a2

Please sign in to comment.