mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-14 00:07:05 +00:00
Merge branch 'shssoichiro-snake-case-support'
This commit is contained in:
commit
145218f116
4 changed files with 6 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1861,6 +1861,7 @@ dependencies = [
|
|||
"async-std",
|
||||
"dotenv",
|
||||
"futures 0.3.4",
|
||||
"heck",
|
||||
"lazy_static",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -39,6 +39,7 @@ async-std = { version = "1.5.0", default-features = false, optional = true }
|
|||
tokio = { version = "0.2.13", default-features = false, features = [ "rt-threaded" ], optional = true }
|
||||
dotenv = { version = "0.15.0", default-features = false }
|
||||
futures = { version = "0.3.4", default-features = false, features = [ "executor" ] }
|
||||
heck = "0.3"
|
||||
proc-macro2 = { version = "1.0.9", default-features = false }
|
||||
sqlx = { version = "0.3.4", default-features = false, path = "../sqlx-core", package = "sqlx-core" }
|
||||
serde_json = { version = "1.0", features = [ "raw_value" ], optional = true }
|
||||
|
|
|
@ -29,6 +29,7 @@ macro_rules! try_set {
|
|||
#[derive(Copy, Clone)]
|
||||
pub enum RenameAll {
|
||||
LowerCase,
|
||||
SnakeCase,
|
||||
}
|
||||
|
||||
pub struct SqlxContainerAttributes {
|
||||
|
@ -68,6 +69,7 @@ pub fn parse_container_attributes(input: &[Attribute]) -> syn::Result<SqlxContai
|
|||
}) if path.is_ident("rename_all") => {
|
||||
let val = match &*val.value() {
|
||||
"lowercase" => RenameAll::LowerCase,
|
||||
"snake_case" => RenameAll::SnakeCase,
|
||||
|
||||
_ => fail!(meta, "unexpected value for rename_all"),
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ pub(crate) use r#type::expand_derive_type;
|
|||
pub(crate) use row::expand_derive_from_row;
|
||||
|
||||
use self::attributes::RenameAll;
|
||||
use heck::SnakeCase;
|
||||
use std::iter::FromIterator;
|
||||
use syn::DeriveInput;
|
||||
|
||||
|
@ -30,5 +31,6 @@ pub(crate) fn expand_derive_type_encode_decode(
|
|||
pub(crate) fn rename_all(s: &str, pattern: RenameAll) -> String {
|
||||
match pattern {
|
||||
RenameAll::LowerCase => s.to_lowercase(),
|
||||
RenameAll::SnakeCase => s.to_snake_case(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue