Function
encode_bind
(
stmt_name: &str,
types: &[Type],
params: P,
portal_name: &str,
buf: &mut BytesMut,
)
Source from the content-addressed store, hash-verified
| 233 | } |
| 234 | |
| 235 | fn encode_bind<P>( |
| 236 | stmt_name: &str, |
| 237 | types: &[Type], |
| 238 | params: P, |
| 239 | portal_name: &str, |
| 240 | buf: &mut BytesMut, |
| 241 | ) -> Result<(), Error> |
| 242 | where |
| 243 | P: AsParams, |
| 244 | { |
| 245 | let params = params.into_iter(); |
| 246 | if params.len() != types.len() { |
| 247 | return Err(Error::from(InvalidParamCount { |
| 248 | expected: types.len(), |
| 249 | params: params.len(), |
| 250 | })); |
| 251 | } |
| 252 | |
| 253 | let params = params.zip(types); |
| 254 | |
| 255 | protocol::bind( |
| 256 | portal_name, |
| 257 | stmt_name, |
| 258 | params.clone().map(|(p, ty)| p.borrow_to_sql().encode_format(ty) as _), |
| 259 | params, |
| 260 | |(p, ty), buf| { |
| 261 | let is_null = p.borrow_to_sql().to_sql_checked(ty, buf)?; |
| 262 | Ok(match is_null { |
| 263 | IsNull::No => protocol::IsNull::No, |
| 264 | IsNull::Yes => protocol::IsNull::Yes, |
| 265 | }) |
| 266 | }, |
| 267 | buf, |
| 268 | ) |
| 269 | } |
Tested by
no test coverage detected