1- use crate :: sql:: { ToSql , PARAM_PREFIX } ;
21use crate :: { docs, Data } ;
32use convert_case:: { Case , Casing } ;
43use endpoint_libs:: model:: { EnumVariant , Field , ProceduralFunction , Type } ;
@@ -106,7 +105,7 @@ impl ToRust for Type {
106105 )
107106 } ) ;
108107 format ! (
109- r#"#[derive(Debug, Clone, Copy, ToSql, FromSql, Serialize, Deserialize, FromPrimitive, PartialEq, Eq, PartialOrd, Ord, EnumString, Display, Hash)]pub enum Enum{} {{{}}}"# ,
108+ r#"#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromPrimitive, PartialEq, Eq, PartialOrd, Ord, EnumString, Display, Hash)]pub enum Enum{} {{{}}}"# ,
110109 name. to_case( Case :: Pascal ) ,
111110 fields. join( "," )
112111 )
@@ -123,45 +122,45 @@ pub fn get_parameter_type(this: &ProceduralFunction) -> Type {
123122 )
124123}
125124
126- pub fn pg_func_to_rust_trait_impl ( this : & ProceduralFunction ) -> String {
127- let mut arguments = this. parameters . iter ( ) . enumerate ( ) . map ( |( i, x) | {
128- format ! (
129- "{}{} => ${}::{}" ,
130- PARAM_PREFIX ,
131- x. name,
132- i + 1 ,
133- x. ty. to_sql( )
134- )
135- } ) ;
136- let sql = format ! ( "SELECT * FROM api.{}({});" , this. name, arguments. join( ", " ) ) ;
137- let pg_params = this
138- . parameters
139- . iter ( )
140- . map ( |x| format ! ( "&self.{} as &(dyn ToSql + Sync)" , x. name) )
141- . join ( ", " ) ;
125+ // pub fn pg_func_to_rust_trait_impl(this: &ProceduralFunction) -> String {
126+ // let mut arguments = this.parameters.iter().enumerate().map(|(i, x)| {
127+ // format!(
128+ // "{}{} => ${}::{}",
129+ // PARAM_PREFIX,
130+ // x.name,
131+ // i + 1,
132+ // x.ty.to_sql()
133+ // )
134+ // });
135+ // let sql = format!("SELECT * FROM api.{}({});", this.name, arguments.join(", "));
136+ // let pg_params = this
137+ // .parameters
138+ // .iter()
139+ // .map(|x| format!("&self.{} as &(dyn ToSql + Sync)", x.name))
140+ // .join(", ");
142141
143- format ! (
144- "
145- #[allow(unused_variables)]
146- impl DatabaseRequest for {name}Req {{
147- type ResponseRow = {ret_name};
148- fn statement(&self) -> &str {{
149- \" {sql}\"
150- }}
151- fn params(&self) -> Vec<&(dyn ToSql + Sync)> {{
152- vec![{pg_params}]
153- }}
154- }}
155- " ,
156- name = this. name. to_case( Case :: Pascal ) ,
157- ret_name = match & this. return_row_type {
158- Type :: Struct { name, .. } => name,
159- _ => unreachable!( ) ,
160- } ,
161- sql = sql,
162- pg_params = pg_params,
163- )
164- }
142+ // format!(
143+ // "
144+ // #[allow(unused_variables)]
145+ // impl DatabaseRequest for {name}Req {{
146+ // type ResponseRow = {ret_name};
147+ // fn statement(&self) -> &str {{
148+ // \"{sql}\"
149+ // }}
150+ // fn params(&self) -> Vec<&(dyn ToSql + Sync)> {{
151+ // vec![{pg_params}]
152+ // }}
153+ // }}
154+ // ",
155+ // name = this.name.to_case(Case::Pascal),
156+ // ret_name = match &this.return_row_type {
157+ // Type::Struct { name, .. } => name,
158+ // _ => unreachable!(),
159+ // },
160+ // sql = sql,
161+ // pg_params = pg_params,
162+ // )
163+ // }
165164
166165pub fn collect_rust_recursive_types ( t : Type ) -> Vec < Type > {
167166 match t {
0 commit comments