sqlx-macros-0.7.3/.cargo_vcs_info.json0000644000000001510000000000100133110ustar { "git": { "sha1": "c55aba0dc14f33b8a26cab6af565fcc4c8af8962" }, "path_in_vcs": "sqlx-macros" }sqlx-macros-0.7.3/Cargo.toml0000644000000037470000000000100113250ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "sqlx-macros" version = "0.7.3" authors = [ "Ryan Leckey ", "Austin Bonander ", "Chloe Ross ", "Daniel Akhterov ", ] description = "Macros for SQLx, the rust SQL toolkit. Not intended to be used directly." license = "MIT OR Apache-2.0" repository = "https://github.com/launchbadge/sqlx" [lib] proc-macro = true [dependencies.proc-macro2] version = "1.0.36" default-features = false [dependencies.quote] version = "1.0.14" default-features = false [dependencies.sqlx-core] version = "=0.7.3" features = ["any"] [dependencies.sqlx-macros-core] version = "=0.7.3" [dependencies.syn] version = "1.0.84" features = [ "parsing", "proc-macro", ] default-features = false [features] _rt-async-std = ["sqlx-macros-core/_rt-async-std"] _rt-tokio = ["sqlx-macros-core/_rt-tokio"] _tls-native-tls = ["sqlx-macros-core/_tls-native-tls"] _tls-rustls = ["sqlx-macros-core/_tls-rustls"] bigdecimal = ["sqlx-macros-core/bigdecimal"] bit-vec = ["sqlx-macros-core/bit-vec"] chrono = ["sqlx-macros-core/chrono"] default = [] ipnetwork = ["sqlx-macros-core/ipnetwork"] json = ["sqlx-macros-core/json"] mac_address = ["sqlx-macros-core/mac_address"] migrate = ["sqlx-macros-core/migrate"] mysql = ["sqlx-macros-core/mysql"] postgres = ["sqlx-macros-core/postgres"] rust_decimal = ["sqlx-macros-core/rust_decimal"] sqlite = ["sqlx-macros-core/sqlite"] time = ["sqlx-macros-core/time"] uuid = ["sqlx-macros-core/uuid"] sqlx-macros-0.7.3/Cargo.toml.orig000064400000000000000000000025650072674642500150330ustar 00000000000000[package] name = "sqlx-macros" description = "Macros for SQLx, the rust SQL toolkit. Not intended to be used directly." version.workspace = true license.workspace = true edition.workspace = true authors.workspace = true repository.workspace = true [lib] proc-macro = true [features] default = [] # for conditional compilation _rt-async-std = ["sqlx-macros-core/_rt-async-std"] _rt-tokio = ["sqlx-macros-core/_rt-tokio"] _tls-native-tls = ["sqlx-macros-core/_tls-native-tls"] _tls-rustls = ["sqlx-macros-core/_tls-rustls"] # SQLx features migrate = ["sqlx-macros-core/migrate"] # database mysql = ["sqlx-macros-core/mysql"] postgres = ["sqlx-macros-core/postgres"] sqlite = ["sqlx-macros-core/sqlite"] # type bigdecimal = ["sqlx-macros-core/bigdecimal"] bit-vec = ["sqlx-macros-core/bit-vec"] chrono = ["sqlx-macros-core/chrono"] ipnetwork = ["sqlx-macros-core/ipnetwork"] mac_address = ["sqlx-macros-core/mac_address"] rust_decimal = ["sqlx-macros-core/rust_decimal"] time = ["sqlx-macros-core/time"] uuid = ["sqlx-macros-core/uuid"] json = ["sqlx-macros-core/json"] [dependencies] sqlx-core = { workspace = true, features = ["any"] } sqlx-macros-core = { workspace = true } proc-macro2 = { version = "1.0.36", default-features = false } syn = { version = "1.0.84", default-features = false, features = ["parsing", "proc-macro"] } quote = { version = "1.0.14", default-features = false } sqlx-macros-0.7.3/src/lib.rs000064400000000000000000000057240072674642500140470ustar 00000000000000use proc_macro::TokenStream; use quote::quote; use sqlx_macros_core::*; #[proc_macro] pub fn expand_query(input: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(input as query::QueryMacroInput); match query::expand_input(input, FOSS_DRIVERS) { Ok(ts) => ts.into(), Err(e) => { if let Some(parse_err) = e.downcast_ref::() { parse_err.to_compile_error().into() } else { let msg = e.to_string(); quote!(::std::compile_error!(#msg)).into() } } } } #[proc_macro_derive(Encode, attributes(sqlx))] pub fn derive_encode(tokenstream: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(tokenstream as syn::DeriveInput); match derives::expand_derive_encode(&input) { Ok(ts) => ts.into(), Err(e) => e.to_compile_error().into(), } } #[proc_macro_derive(Decode, attributes(sqlx))] pub fn derive_decode(tokenstream: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(tokenstream as syn::DeriveInput); match derives::expand_derive_decode(&input) { Ok(ts) => ts.into(), Err(e) => e.to_compile_error().into(), } } #[proc_macro_derive(Type, attributes(sqlx))] pub fn derive_type(tokenstream: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(tokenstream as syn::DeriveInput); match derives::expand_derive_type_encode_decode(&input) { Ok(ts) => ts.into(), Err(e) => e.to_compile_error().into(), } } #[proc_macro_derive(FromRow, attributes(sqlx))] pub fn derive_from_row(input: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(input as syn::DeriveInput); match derives::expand_derive_from_row(&input) { Ok(ts) => ts.into(), Err(e) => e.to_compile_error().into(), } } #[cfg(feature = "migrate")] #[proc_macro] pub fn migrate(input: TokenStream) -> TokenStream { use syn::LitStr; let input = syn::parse_macro_input!(input as LitStr); match migrate::expand_migrator_from_lit_dir(input) { Ok(ts) => ts.into(), Err(e) => { if let Some(parse_err) = e.downcast_ref::() { parse_err.to_compile_error().into() } else { let msg = e.to_string(); quote!(::std::compile_error!(#msg)).into() } } } } #[proc_macro_attribute] pub fn test(args: TokenStream, input: TokenStream) -> TokenStream { let args = syn::parse_macro_input!(args as syn::AttributeArgs); let input = syn::parse_macro_input!(input as syn::ItemFn); match test_attr::expand(args, input) { Ok(ts) => ts.into(), Err(e) => { if let Some(parse_err) = e.downcast_ref::() { parse_err.to_compile_error().into() } else { let msg = e.to_string(); quote!(::std::compile_error!(#msg)).into() } } } }