Execute basic query without statement caching
(
&self,
conn: &Connection,
query: &str,
params: P,
)
| 162 | |
| 163 | /// Execute basic query without statement caching |
| 164 | fn execute_basic_query<P: rusqlite::Params>( |
| 165 | &self, |
| 166 | conn: &Connection, |
| 167 | query: &str, |
| 168 | params: P, |
| 169 | ) -> Result<(Vec<String>, crate::session::db_handler::DbRows), rusqlite::Error> { |
| 170 | let mut stmt = conn.prepare(query)?; |
| 171 | let column_names: Vec<String> = stmt.column_names().iter().map(|&s| s.to_string()).collect(); |
| 172 | |
| 173 | let mut results = Vec::new(); |
| 174 | let rows = stmt.query_map(params, |row| { |
| 175 | let mut row_data = Vec::new(); |
| 176 | for i in 0..column_names.len() { |
| 177 | match row.get_ref(i)? { |
| 178 | rusqlite::types::ValueRef::Null => row_data.push(None), |
| 179 | rusqlite::types::ValueRef::Integer(val) => { |
| 180 | row_data.push(Some(val.to_string().into_bytes())); |
| 181 | }, |
| 182 | rusqlite::types::ValueRef::Real(val) => { |
| 183 | row_data.push(Some(val.to_string().into_bytes())); |
| 184 | }, |
| 185 | rusqlite::types::ValueRef::Text(val) => { |
| 186 | row_data.push(Some(val.to_vec())); |
| 187 | }, |
| 188 | rusqlite::types::ValueRef::Blob(val) => { |
| 189 | row_data.push(Some(val.to_vec())); |
| 190 | }, |
| 191 | } |
| 192 | } |
| 193 | Ok(row_data) |
| 194 | })?; |
| 195 | |
| 196 | for row_result in rows { |
| 197 | results.push(row_result?); |
| 198 | } |
| 199 | |
| 200 | Ok((column_names, results)) |
| 201 | } |
| 202 | |
| 203 | /// Determine if a query should use statement caching based on pattern and hints |
| 204 | fn should_use_statement_cache(&self, pattern: &QueryPattern, hints: &OptimizationHints) -> bool { |
no test coverage detected