Skip to content

Commit 708f753

Browse files
author
Daniil Babin
committed
Fixed clippy errors
1 parent 0671b65 commit 708f753

File tree

3 files changed

+11
-28
lines changed

3 files changed

+11
-28
lines changed

src/statement/parameters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
},
1717
};
1818

19-
pub type QueryParameter = (dyn ToSql + Sync);
19+
pub type QueryParameter = dyn ToSql + Sync;
2020

2121
#[pyclass]
2222
#[derive(Default, Clone, Debug)]

src/value_converter/dto/impls.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,14 @@ impl ToSql for PythonDTO {
177177
<Vec<u8> as ToSql>::to_sql(pybytes, ty, out)?;
178178
}
179179
PythonDTO::PyBool(boolean) => types::bool_to_sql(*boolean, out),
180-
PythonDTO::PyVarChar(string) => {
181-
<&str as ToSql>::to_sql(&string.as_str(), ty, out)?;
182-
}
183-
PythonDTO::PyText(string) => {
180+
PythonDTO::PyVarChar(string)
181+
| PythonDTO::PyText(string)
182+
| PythonDTO::PyString(string) => {
184183
<&str as ToSql>::to_sql(&string.as_str(), ty, out)?;
185184
}
186185
PythonDTO::PyUUID(pyuuid) => {
187186
<Uuid as ToSql>::to_sql(pyuuid, ty, out)?;
188187
}
189-
PythonDTO::PyString(string) => {
190-
<&str as ToSql>::to_sql(&string.as_str(), ty, out)?;
191-
}
192188
PythonDTO::PyIntI16(int) => out.put_i16(*int),
193189
PythonDTO::PyIntI32(int) => out.put_i32(*int),
194190
PythonDTO::PyIntI64(int) | PythonDTO::PyMoney(int) => out.put_i64(*int),

src/value_converter/to_python.rs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,11 @@ fn postgres_bytes_to_py(
180180
}
181181
Ok(py.None())
182182
}
183-
Type::OID => Ok(
184-
composite_field_postgres_to_py::<Option<i32>>(type_, buf, is_simple)?
185-
.into_py_any(py)?,
186-
),
187-
Type::NAME => Ok(
188-
composite_field_postgres_to_py::<Option<String>>(type_, buf, is_simple)?
189-
.into_py_any(py)?,
190-
),
183+
// Convert Integer into i32, then into int
184+
Type::OID | Type::INT4 => Ok(composite_field_postgres_to_py::<Option<i32>>(
185+
type_, buf, is_simple,
186+
)?
187+
.into_py_any(py)?),
191188
// // ---------- String Types ----------
192189
// // Convert TEXT and VARCHAR type into String, then into str
193190
Type::TEXT | Type::VARCHAR | Type::XML => Ok(composite_field_postgres_to_py::<
@@ -206,11 +203,6 @@ fn postgres_bytes_to_py(
206203
composite_field_postgres_to_py::<Option<i16>>(type_, buf, is_simple)?
207204
.into_py_any(py)?,
208205
),
209-
// Convert Integer into i32, then into int
210-
Type::INT4 => Ok(
211-
composite_field_postgres_to_py::<Option<i32>>(type_, buf, is_simple)?
212-
.into_py_any(py)?,
213-
),
214206
// Convert BigInt into i64, then into int
215207
Type::INT8 | Type::MONEY => Ok(composite_field_postgres_to_py::<Option<i64>>(
216208
type_, buf, is_simple,
@@ -363,7 +355,8 @@ fn postgres_bytes_to_py(
363355
composite_field_postgres_to_py::<Option<Array<bool>>>(type_, buf, is_simple)?,
364356
)
365357
.into_py_any(py)?),
366-
Type::OID_ARRAY => Ok(postgres_array_to_py(
358+
// Convert ARRAY of Integer into Vec<i32>, then into list[int]
359+
Type::OID_ARRAY | Type::INT4_ARRAY => Ok(postgres_array_to_py(
367360
py,
368361
composite_field_postgres_to_py::<Option<Array<i32>>>(type_, buf, is_simple)?,
369362
)
@@ -381,12 +374,6 @@ fn postgres_bytes_to_py(
381374
composite_field_postgres_to_py::<Option<Array<i16>>>(type_, buf, is_simple)?,
382375
)
383376
.into_py_any(py)?),
384-
// Convert ARRAY of Integer into Vec<i32>, then into list[int]
385-
Type::INT4_ARRAY => Ok(postgres_array_to_py(
386-
py,
387-
composite_field_postgres_to_py::<Option<Array<i32>>>(type_, buf, is_simple)?,
388-
)
389-
.into_py_any(py)?),
390377
// Convert ARRAY of BigInt into Vec<i64>, then into list[int]
391378
Type::INT8_ARRAY | Type::MONEY_ARRAY => Ok(postgres_array_to_py(
392379
py,

0 commit comments

Comments
 (0)