Skip to content

Commit f42f69f

Browse files
committed
refactor: Simplify ODBC connection execution and enhance SQL handling
This commit refactors the ODBC connection executor and worker to streamline SQL execution processes. It introduces helper functions for executing SQL commands and collecting results, improving code readability and maintainability. Additionally, it updates the handling of SQL query results to enhance performance and clarity.
1 parent 2629cf0 commit f42f69f

File tree

7 files changed

+161
-208
lines changed

7 files changed

+161
-208
lines changed

sqlx-core/src/column.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl<T: ?Sized, I: ColumnIndex<T> + ?Sized> ColumnIndex<T> for &'_ I {
5555
}
5656
}
5757

58+
#[allow(unused_macros)]
5859
macro_rules! impl_column_index_for_row {
5960
($R:ident) => {
6061
impl crate::column::ColumnIndex<$R> for usize {
@@ -71,6 +72,7 @@ macro_rules! impl_column_index_for_row {
7172
};
7273
}
7374

75+
#[allow(unused_macros)]
7476
macro_rules! impl_column_index_for_statement {
7577
($S:ident) => {
7678
impl crate::column::ColumnIndex<$S<'_>> for usize {

sqlx-core/src/common/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mod statement_cache;
22

3+
#[allow(unused_imports)]
34
pub(crate) use statement_cache::StatementCache;
45
use std::fmt::{Debug, Formatter};
56
use std::ops::{Deref, DerefMut};

sqlx-core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,6 @@ pub mod testing;
116116
pub use sqlx_rt::test_block_on;
117117

118118
/// sqlx uses ahash for increased performance, at the cost of reduced DoS resistance.
119+
#[allow(unused_imports)]
119120
use ahash::AHashMap as HashMap;
120121
//type HashMap<K, V> = std::collections::HashMap<K, V, ahash::RandomState>;

sqlx-core/src/odbc/connection/executor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ impl<'c> Executor<'c> for &'c mut OdbcConnection {
8888
fn interpolate_sql_with_odbc_args(sql: &str, args: &[OdbcArgumentValue<'_>]) -> String {
8989
let mut result = String::with_capacity(sql.len() + args.len() * 8);
9090
let mut arg_iter = args.iter();
91-
let mut chars = sql.chars().peekable();
92-
while let Some(ch) = chars.next() {
91+
for ch in sql.chars() {
9392
if ch == '?' {
9493
if let Some(arg) = arg_iter.next() {
9594
match arg {

sqlx-core/src/odbc/connection/worker.rs

Lines changed: 154 additions & 205 deletions
Large diffs are not rendered by default.

sqlx-core/src/odbc/type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Type<Odbc> for String {
6262
}
6363
}
6464

65-
impl<'a> Type<Odbc> for &'a str {
65+
impl Type<Odbc> for &str {
6666
fn type_info() -> OdbcTypeInfo {
6767
OdbcTypeInfo {
6868
name: "TEXT".into(),

sqlx-core/src/statement.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub trait Statement<'q>: Send + Sync {
8888
A: IntoArguments<'s, Self::Database>;
8989
}
9090

91+
#[allow(unused_macros)]
9192
macro_rules! impl_statement_query {
9293
($A:ty) => {
9394
#[inline]

0 commit comments

Comments
 (0)