Skip to content

Commit dec3552

Browse files
committed
rename with_param to param
1 parent 1fba9d9 commit dec3552

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Client {
162162
}
163163

164164
/// Specify server side parameter for all this client's queries.
165-
pub fn with_param(self, name: &str, value: impl Serialize) -> Result<Self, String> {
165+
pub fn param(self, name: &str, value: impl Serialize) -> Result<Self, String> {
166166
let mut param = String::from("");
167167
ser::write_param(&mut param, &value)?;
168168
Ok(self.with_option(format!("param_{name}"), param))

src/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl Query {
200200
/// Specify server side parameter for query.
201201
///
202202
/// In queries you can reference params as {name: type} e.g. {val: Int32}.
203-
pub fn with_param(mut self, name: &str, value: impl Serialize) -> Self {
203+
pub fn param(mut self, name: &str, value: impl Serialize) -> Self {
204204
let mut param = String::from("");
205205
if let Err(err) = ser::write_param(&mut param, &value) {
206206
self.sql = SqlBuilder::Failed(format!("invalid param: {err}"));

tests/it/query.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,36 +88,36 @@ async fn fetch_one_and_optional() {
8888
#[tokio::test]
8989
async fn server_side_param() {
9090
let client = prepare_database!()
91-
.with_param("val1", 42)
91+
.param("val1", 42)
9292
.expect("failed to bind 42");
9393

9494
let result = client
9595
.query("SELECT plus({val1: Int32}, {val2: Int32}) AS result")
96-
.with_param("val2", 144)
96+
.param("val2", 144)
9797
.fetch_one::<u64>()
9898
.await
9999
.expect("failed to fetch u64");
100100
assert_eq!(result, 186);
101101

102102
let result = client
103103
.query("SELECT {val1: String} AS result")
104-
.with_param("val1", "string")
104+
.param("val1", "string")
105105
.fetch_one::<String>()
106106
.await
107107
.expect("failed to fetch string");
108108
assert_eq!(result, "string");
109109

110110
let result = client
111111
.query("SELECT {val1: String} AS result")
112-
.with_param("val1", "\x01\x02\x03\\ \"\'")
112+
.param("val1", "\x01\x02\x03\\ \"\'")
113113
.fetch_one::<String>()
114114
.await
115115
.expect("failed to fetch string");
116116
assert_eq!(result, "\x01\x02\x03\\ \"\'");
117117

118118
let result = client
119119
.query("SELECT {val1: Array(String)} AS result")
120-
.with_param("val1", vec!["a", "bc"])
120+
.param("val1", vec!["a", "bc"])
121121
.fetch_one::<Vec<String>>()
122122
.await
123123
.expect("failed to fetch string");

0 commit comments

Comments
 (0)