Skip to content

Commit 883c606

Browse files
committed
remove from and to sql
1 parent ec68094 commit 883c606

File tree

2 files changed

+40
-41
lines changed

2 files changed

+40
-41
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "endpoint-gen"
5-
version = "0.4.1"
5+
version = "0.4.3"
66
edition = "2021"
77
repository = "https://github.com/pathscale/EndpointGen/"
88
description = "Generate Rust code for websocket API endpoints"

src/rust.rs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::sql::{ToSql, PARAM_PREFIX};
21
use crate::{docs, Data};
32
use convert_case::{Case, Casing};
43
use 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

166165
pub fn collect_rust_recursive_types(t: Type) -> Vec<Type> {
167166
match t {

0 commit comments

Comments
 (0)