Verify parameter list length and type
(&self, expect: &[FieldRef])
| 47 | |
| 48 | /// Verify parameter list length and type |
| 49 | pub fn verify_fields(&self, expect: &[FieldRef]) -> Result<()> { |
| 50 | match self { |
| 51 | ParamValues::List(list) => { |
| 52 | // Verify if the number of params matches the number of values |
| 53 | if expect.len() != list.len() { |
| 54 | return _plan_err!( |
| 55 | "Expected {} parameters, got {}", |
| 56 | expect.len(), |
| 57 | list.len() |
| 58 | ); |
| 59 | } |
| 60 | |
| 61 | // Verify if the types of the params matches the types of the values |
| 62 | let iter = expect.iter().zip(list.iter()); |
| 63 | for (i, (param_type, lit)) in iter.enumerate() { |
| 64 | check_metadata_with_storage_equal( |
| 65 | ( |
| 66 | &lit.value.data_type(), |
| 67 | lit.metadata.as_ref().map(|m| m.to_hashmap()).as_ref(), |
| 68 | ), |
| 69 | (param_type.data_type(), Some(param_type.metadata())), |
| 70 | "parameter", |
| 71 | &format!(" at index {i}"), |
| 72 | )?; |
| 73 | } |
| 74 | Ok(()) |
| 75 | } |
| 76 | ParamValues::Map(_) => { |
| 77 | // If it is a named query, variables can be reused, |
| 78 | // but the lengths are not necessarily equal |
| 79 | Ok(()) |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | pub fn get_placeholders_with_values(&self, id: &str) -> Result<ScalarAndMetadata> { |
| 85 | match self { |
no test coverage detected