@@ -29,6 +29,9 @@ pub enum TableFieldAttr {
29
29
GetOptional ( Getter ) ,
30
30
// get_many [= <ident>]? [(<type>)]?
31
31
GetMany ( Getter ) ,
32
+ // get_many [= <ident>]? [(<type>)]?
33
+ #[ cfg( feature = "postgres" ) ]
34
+ GetAny ( Getter ) ,
32
35
// set [= <ident>]?
33
36
Set ( Option < Ident > ) ,
34
37
}
@@ -95,14 +98,16 @@ pub fn parse_attrs<A: Parse>(attrs: &[Attribute]) -> Result<Vec<A>> {
95
98
macro_rules! impl_parse {
96
99
// entry point
97
100
( $i: ident {
98
- $( $s: literal => $v: ident( $( $t: tt) * ) ) ,*
101
+ $( $( # [ cfg ( $cfg_attr : meta ) ] ) ? $ s: literal => $v: ident( $( $t: tt) * ) ) ,*
99
102
} ) => {
100
103
impl syn:: parse:: Parse for $i {
101
104
#[ allow( clippy:: redundant_closure_call) ]
102
105
fn parse( input: syn:: parse:: ParseStream ) -> syn:: Result <Self > {
103
106
let ident = input. parse:: <syn:: Ident >( ) ?;
104
107
match & * ident. to_string( ) {
105
- $( $s => ( impl_parse!( $( $t) * ) ) ( input) . map( Self :: $v) , ) *
108
+ $(
109
+ $( #[ cfg( $cfg_attr) ] ) ?
110
+ $s => ( impl_parse!( $( $t) * ) ) ( input) . map( Self :: $v) , ) *
106
111
_ => Err ( input. error( "unknown attribute" ) )
107
112
}
108
113
}
@@ -141,6 +146,8 @@ impl_parse!(TableFieldAttr {
141
146
"get_one" => GetOne ( Getter ) ,
142
147
"get_optional" => GetOptional ( Getter ) ,
143
148
"get_many" => GetMany ( Getter ) ,
149
+ #[ cfg( feature = "postgres" ) ]
150
+ "get_any" => GetAny ( Getter ) ,
144
151
"set" => Set ( ( = Ident ) ?) ,
145
152
"custom_type" => CustomType ( ) ,
146
153
"default" => Default ( )
0 commit comments