mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
Merge pull request #1267 from gwenn/clippy
[breaking change] Update edition from 2018 to 2021
This commit is contained in:
commit
dd05c992c2
@ -3,7 +3,7 @@ name = "rusqlite"
|
|||||||
# Note: Update version in README.md when you change this.
|
# Note: Update version in README.md when you change this.
|
||||||
version = "0.29.0"
|
version = "0.29.0"
|
||||||
authors = ["The rusqlite developers"]
|
authors = ["The rusqlite developers"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
description = "Ergonomic wrapper for SQLite"
|
description = "Ergonomic wrapper for SQLite"
|
||||||
repository = "https://github.com/rusqlite/rusqlite"
|
repository = "https://github.com/rusqlite/rusqlite"
|
||||||
documentation = "https://docs.rs/rusqlite/"
|
documentation = "https://docs.rs/rusqlite/"
|
||||||
|
@ -274,7 +274,6 @@ impl Blob<'_> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
use std::convert::TryInto;
|
|
||||||
self.size().try_into().unwrap()
|
self.size().try_into().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ mod test {
|
|||||||
assert_eq!(ty, Type::Integer);
|
assert_eq!(ty, Type::Integer);
|
||||||
}
|
}
|
||||||
e => {
|
e => {
|
||||||
panic!("Unexpected error type: {:?}", e);
|
panic!("Unexpected error type: {e:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match row.get::<_, String>("y").unwrap_err() {
|
match row.get::<_, String>("y").unwrap_err() {
|
||||||
@ -213,7 +213,7 @@ mod test {
|
|||||||
assert_eq!(ty, Type::Null);
|
assert_eq!(ty, Type::Null);
|
||||||
}
|
}
|
||||||
e => {
|
e => {
|
||||||
panic!("Unexpected error type: {:?}", e);
|
panic!("Unexpected error type: {e:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
17
src/error.rs
17
src/error.rs
@ -252,11 +252,7 @@ impl fmt::Display for Error {
|
|||||||
),
|
),
|
||||||
Error::FromSqlConversionFailure(i, ref t, ref err) => {
|
Error::FromSqlConversionFailure(i, ref t, ref err) => {
|
||||||
if i != UNKNOWN_COLUMN {
|
if i != UNKNOWN_COLUMN {
|
||||||
write!(
|
write!(f, "Conversion error from type {t} at index: {i}, {err}")
|
||||||
f,
|
|
||||||
"Conversion error from type {} at index: {}, {}",
|
|
||||||
t, i, err
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
err.fmt(f)
|
err.fmt(f)
|
||||||
}
|
}
|
||||||
@ -278,15 +274,12 @@ impl fmt::Display for Error {
|
|||||||
Error::QueryReturnedNoRows => write!(f, "Query returned no rows"),
|
Error::QueryReturnedNoRows => write!(f, "Query returned no rows"),
|
||||||
Error::InvalidColumnIndex(i) => write!(f, "Invalid column index: {i}"),
|
Error::InvalidColumnIndex(i) => write!(f, "Invalid column index: {i}"),
|
||||||
Error::InvalidColumnName(ref name) => write!(f, "Invalid column name: {name}"),
|
Error::InvalidColumnName(ref name) => write!(f, "Invalid column name: {name}"),
|
||||||
Error::InvalidColumnType(i, ref name, ref t) => write!(
|
Error::InvalidColumnType(i, ref name, ref t) => {
|
||||||
f,
|
write!(f, "Invalid column type {t} at index: {i}, name: {name}")
|
||||||
"Invalid column type {} at index: {}, name: {}",
|
}
|
||||||
t, i, name
|
|
||||||
),
|
|
||||||
Error::InvalidParameterCount(i1, n1) => write!(
|
Error::InvalidParameterCount(i1, n1) => write!(
|
||||||
f,
|
f,
|
||||||
"Wrong number of parameters passed to query. Got {}, needed {}",
|
"Wrong number of parameters passed to query. Got {i1}, needed {n1}"
|
||||||
i1, n1
|
|
||||||
),
|
),
|
||||||
Error::StatementChangedRows(i) => write!(f, "Query changed {i} rows"),
|
Error::StatementChangedRows(i) => write!(f, "Query changed {i} rows"),
|
||||||
|
|
||||||
|
@ -656,7 +656,7 @@ unsafe fn free_boxed_hook<F>(p: *mut c_void) {
|
|||||||
|
|
||||||
unsafe fn expect_utf8<'a>(p_str: *const c_char, description: &'static str) -> &'a str {
|
unsafe fn expect_utf8<'a>(p_str: *const c_char, description: &'static str) -> &'a str {
|
||||||
expect_optional_utf8(p_str, description)
|
expect_optional_utf8(p_str, description)
|
||||||
.unwrap_or_else(|| panic!("received empty {}", description))
|
.unwrap_or_else(|| panic!("received empty {description}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn expect_optional_utf8<'a>(
|
unsafe fn expect_optional_utf8<'a>(
|
||||||
@ -667,7 +667,7 @@ unsafe fn expect_optional_utf8<'a>(
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
std::str::from_utf8(std::ffi::CStr::from_ptr(p_str).to_bytes())
|
std::str::from_utf8(std::ffi::CStr::from_ptr(p_str).to_bytes())
|
||||||
.unwrap_or_else(|_| panic!("received non-utf8 string as {}", description))
|
.unwrap_or_else(|_| panic!("received non-utf8 string as {description}"))
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
31
src/lib.rs
31
src/lib.rs
@ -1307,9 +1307,7 @@ mod test {
|
|||||||
assert_eq!(ffi::SQLITE_CANTOPEN, e.extended_code);
|
assert_eq!(ffi::SQLITE_CANTOPEN, e.extended_code);
|
||||||
assert!(
|
assert!(
|
||||||
msg.contains(filename),
|
msg.contains(filename),
|
||||||
"error message '{}' does not contain '{}'",
|
"error message '{msg}' does not contain '{filename}'"
|
||||||
msg,
|
|
||||||
filename
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
panic!("SqliteFailure expected");
|
panic!("SqliteFailure expected");
|
||||||
@ -1437,8 +1435,7 @@ mod test {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
err,
|
err,
|
||||||
Error::ExecuteReturnedResults,
|
Error::ExecuteReturnedResults,
|
||||||
"Unexpected error: {}",
|
"Unexpected error: {err}"
|
||||||
err
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1454,7 +1451,7 @@ mod test {
|
|||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
match err {
|
match err {
|
||||||
Error::MultipleStatement => (),
|
Error::MultipleStatement => (),
|
||||||
_ => panic!("Unexpected error: {}", err),
|
_ => panic!("Unexpected error: {err}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1565,7 +1562,7 @@ mod test {
|
|||||||
let result: Result<i64> = db.one_column("SELECT x FROM foo WHERE x > 5");
|
let result: Result<i64> = db.one_column("SELECT x FROM foo WHERE x > 5");
|
||||||
match result.unwrap_err() {
|
match result.unwrap_err() {
|
||||||
Error::QueryReturnedNoRows => (),
|
Error::QueryReturnedNoRows => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let bad_query_result = db.query_row("NOT A PROPER QUERY; test123", [], |_| Ok(()));
|
let bad_query_result = db.query_row("NOT A PROPER QUERY; test123", [], |_| Ok(()));
|
||||||
@ -1617,7 +1614,7 @@ mod test {
|
|||||||
// > MEMORY or OFF and can not be changed to a different value. An
|
// > MEMORY or OFF and can not be changed to a different value. An
|
||||||
// > attempt to change the journal_mode of an in-memory database to
|
// > attempt to change the journal_mode of an in-memory database to
|
||||||
// > any setting other than MEMORY or OFF is ignored.
|
// > any setting other than MEMORY or OFF is ignored.
|
||||||
assert!(mode == "memory" || mode == "off", "Got mode {:?}", mode);
|
assert!(mode == "memory" || mode == "off", "Got mode {mode:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -1704,7 +1701,7 @@ mod test {
|
|||||||
assert_eq!(err.code, ErrorCode::ConstraintViolation);
|
assert_eq!(err.code, ErrorCode::ConstraintViolation);
|
||||||
check_extended_code(err.extended_code);
|
check_extended_code(err.extended_code);
|
||||||
}
|
}
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1896,7 +1893,7 @@ mod test {
|
|||||||
|
|
||||||
match bad_type.unwrap_err() {
|
match bad_type.unwrap_err() {
|
||||||
Error::InvalidColumnType(..) => (),
|
Error::InvalidColumnType(..) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let bad_idx: Result<Vec<String>> =
|
let bad_idx: Result<Vec<String>> =
|
||||||
@ -1904,7 +1901,7 @@ mod test {
|
|||||||
|
|
||||||
match bad_idx.unwrap_err() {
|
match bad_idx.unwrap_err() {
|
||||||
Error::InvalidColumnIndex(_) => (),
|
Error::InvalidColumnIndex(_) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1949,7 +1946,7 @@ mod test {
|
|||||||
|
|
||||||
match bad_type.unwrap_err() {
|
match bad_type.unwrap_err() {
|
||||||
CustomError::Sqlite(Error::InvalidColumnType(..)) => (),
|
CustomError::Sqlite(Error::InvalidColumnType(..)) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let bad_idx: CustomResult<Vec<String>> = query
|
let bad_idx: CustomResult<Vec<String>> = query
|
||||||
@ -1958,7 +1955,7 @@ mod test {
|
|||||||
|
|
||||||
match bad_idx.unwrap_err() {
|
match bad_idx.unwrap_err() {
|
||||||
CustomError::Sqlite(Error::InvalidColumnIndex(_)) => (),
|
CustomError::Sqlite(Error::InvalidColumnIndex(_)) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let non_sqlite_err: CustomResult<Vec<String>> = query
|
let non_sqlite_err: CustomResult<Vec<String>> = query
|
||||||
@ -1967,7 +1964,7 @@ mod test {
|
|||||||
|
|
||||||
match non_sqlite_err.unwrap_err() {
|
match non_sqlite_err.unwrap_err() {
|
||||||
CustomError::SomeError => (),
|
CustomError::SomeError => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -2004,7 +2001,7 @@ mod test {
|
|||||||
|
|
||||||
match bad_type.unwrap_err() {
|
match bad_type.unwrap_err() {
|
||||||
CustomError::Sqlite(Error::InvalidColumnType(..)) => (),
|
CustomError::Sqlite(Error::InvalidColumnType(..)) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let bad_idx: CustomResult<String> =
|
let bad_idx: CustomResult<String> =
|
||||||
@ -2012,7 +2009,7 @@ mod test {
|
|||||||
|
|
||||||
match bad_idx.unwrap_err() {
|
match bad_idx.unwrap_err() {
|
||||||
CustomError::Sqlite(Error::InvalidColumnIndex(_)) => (),
|
CustomError::Sqlite(Error::InvalidColumnIndex(_)) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let non_sqlite_err: CustomResult<String> =
|
let non_sqlite_err: CustomResult<String> =
|
||||||
@ -2020,7 +2017,7 @@ mod test {
|
|||||||
|
|
||||||
match non_sqlite_err.unwrap_err() {
|
match non_sqlite_err.unwrap_err() {
|
||||||
CustomError::SomeError => (),
|
CustomError::SomeError => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -405,18 +405,17 @@ mod test {
|
|||||||
db.pragma_update_and_check(None, "journal_mode", "OFF", |row| row.get(0))?;
|
db.pragma_update_and_check(None, "journal_mode", "OFF", |row| row.get(0))?;
|
||||||
assert!(
|
assert!(
|
||||||
journal_mode == "off" || journal_mode == "memory",
|
journal_mode == "off" || journal_mode == "memory",
|
||||||
"mode: {:?}",
|
"mode: {journal_mode:?}"
|
||||||
journal_mode,
|
|
||||||
);
|
);
|
||||||
// Sanity checks to ensure the move to a generic `ToSql` wasn't breaking
|
// Sanity checks to ensure the move to a generic `ToSql` wasn't breaking
|
||||||
let mode =
|
let mode =
|
||||||
db.pragma_update_and_check(None, "journal_mode", "OFF", |row| row.get::<_, String>(0))?;
|
db.pragma_update_and_check(None, "journal_mode", "OFF", |row| row.get::<_, String>(0))?;
|
||||||
assert!(mode == "off" || mode == "memory", "mode: {:?}", mode);
|
assert!(mode == "off" || mode == "memory", "mode: {mode:?}");
|
||||||
|
|
||||||
let param: &dyn crate::ToSql = &"OFF";
|
let param: &dyn crate::ToSql = &"OFF";
|
||||||
let mode =
|
let mode =
|
||||||
db.pragma_update_and_check(None, "journal_mode", param, |row| row.get::<_, String>(0))?;
|
db.pragma_update_and_check(None, "journal_mode", param, |row| row.get::<_, String>(0))?;
|
||||||
assert!(mode == "off" || mode == "memory", "mode: {:?}", mode);
|
assert!(mode == "off" || mode == "memory", "mode: {mode:?}");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,12 +1081,12 @@ mod test {
|
|||||||
assert_eq!(stmt.insert([2i32])?, 2);
|
assert_eq!(stmt.insert([2i32])?, 2);
|
||||||
match stmt.insert([1i32]).unwrap_err() {
|
match stmt.insert([1i32]).unwrap_err() {
|
||||||
Error::StatementChangedRows(0) => (),
|
Error::StatementChangedRows(0) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
let mut multi = db.prepare("INSERT INTO foo (x) SELECT 3 UNION ALL SELECT 4")?;
|
let mut multi = db.prepare("INSERT INTO foo (x) SELECT 3 UNION ALL SELECT 4")?;
|
||||||
match multi.insert([]).unwrap_err() {
|
match multi.insert([]).unwrap_err() {
|
||||||
Error::StatementChangedRows(2) => (),
|
Error::StatementChangedRows(2) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1349,7 +1349,7 @@ mod test {
|
|||||||
assert_eq!(error.code, ErrorCode::Unknown);
|
assert_eq!(error.code, ErrorCode::Unknown);
|
||||||
assert_eq!(offset, 7);
|
assert_eq!(offset, 7);
|
||||||
}
|
}
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {err}"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ mod test {
|
|||||||
assert_eq!(e.code, crate::ErrorCode::Unknown);
|
assert_eq!(e.code, crate::ErrorCode::Unknown);
|
||||||
assert!(m.contains("transaction"));
|
assert!(m.contains("transaction"));
|
||||||
} else {
|
} else {
|
||||||
panic!("Unexpected error type: {:?}", e);
|
panic!("Unexpected error type: {e:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +59,7 @@ impl fmt::Display for FromSqlError {
|
|||||||
} => {
|
} => {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"Cannot read {} byte value out of {} byte blob",
|
"Cannot read {expected_size} byte value out of {blob_size} byte blob"
|
||||||
expected_size, blob_size
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
FromSqlError::Other(ref err) => err.fmt(f),
|
FromSqlError::Other(ref err) => err.fmt(f),
|
||||||
@ -273,7 +272,7 @@ mod test {
|
|||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
match err {
|
match err {
|
||||||
Error::IntegralValueOutOfRange(_, value) => assert_eq!(*n, value),
|
Error::IntegralValueOutOfRange(_, value) => assert_eq!(*n, value),
|
||||||
_ => panic!("unexpected error: {}", err),
|
_ => panic!("unexpected error: {err}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for n in in_range {
|
for n in in_range {
|
||||||
|
@ -353,7 +353,7 @@ mod test {
|
|||||||
assert_eq!(Value::Integer(1), row.get::<_, Value>(2)?);
|
assert_eq!(Value::Integer(1), row.get::<_, Value>(2)?);
|
||||||
match row.get::<_, Value>(3)? {
|
match row.get::<_, Value>(3)? {
|
||||||
Value::Real(val) => assert!((1.5 - val).abs() < f64::EPSILON),
|
Value::Real(val) => assert!((1.5 - val).abs() < f64::EPSILON),
|
||||||
x => panic!("Invalid Value {:?}", x),
|
x => panic!("Invalid Value {x:?}"),
|
||||||
}
|
}
|
||||||
assert_eq!(Value::Null, row.get::<_, Value>(4)?);
|
assert_eq!(Value::Null, row.get::<_, Value>(4)?);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -74,7 +74,7 @@ mod test {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
e => {
|
e => {
|
||||||
panic!("Expected conversion failure, got {}", e);
|
panic!("Expected conversion failure, got {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -106,7 +106,6 @@ impl SqliteMallocString {
|
|||||||
/// This means it's safe to use in extern "C" functions even outside of
|
/// This means it's safe to use in extern "C" functions even outside of
|
||||||
/// `catch_unwind`.
|
/// `catch_unwind`.
|
||||||
pub(crate) fn from_str(s: &str) -> Self {
|
pub(crate) fn from_str(s: &str) -> Self {
|
||||||
use std::convert::TryFrom;
|
|
||||||
let s = if s.as_bytes().contains(&0) {
|
let s = if s.as_bytes().contains(&0) {
|
||||||
std::borrow::Cow::Owned(make_nonnull(s))
|
std::borrow::Cow::Owned(make_nonnull(s))
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,10 +113,7 @@ unsafe impl<'vtab> VTab<'vtab> for CsvTab {
|
|||||||
match param {
|
match param {
|
||||||
"filename" => {
|
"filename" => {
|
||||||
if !Path::new(value).exists() {
|
if !Path::new(value).exists() {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!("file '{value}' does not exist")));
|
||||||
"file '{}' does not exist",
|
|
||||||
value
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
vtab.filename = value.to_owned();
|
vtab.filename = value.to_owned();
|
||||||
}
|
}
|
||||||
@ -137,8 +134,7 @@ unsafe impl<'vtab> VTab<'vtab> for CsvTab {
|
|||||||
n_col = Some(n);
|
n_col = Some(n);
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"unrecognized argument to 'columns': {}",
|
"unrecognized argument to 'columns': {value}"
|
||||||
value
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,8 +143,7 @@ unsafe impl<'vtab> VTab<'vtab> for CsvTab {
|
|||||||
vtab.has_headers = b;
|
vtab.has_headers = b;
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"unrecognized argument to 'header': {}",
|
"unrecognized argument to 'header': {value}"
|
||||||
value
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,8 +152,7 @@ unsafe impl<'vtab> VTab<'vtab> for CsvTab {
|
|||||||
vtab.delimiter = b;
|
vtab.delimiter = b;
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"unrecognized argument to 'delimiter': {}",
|
"unrecognized argument to 'delimiter': {value}"
|
||||||
value
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,15 +165,13 @@ unsafe impl<'vtab> VTab<'vtab> for CsvTab {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"unrecognized argument to 'quote': {}",
|
"unrecognized argument to 'quote': {value}"
|
||||||
value
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"unrecognized parameter '{}'",
|
"unrecognized parameter '{param}'"
|
||||||
param
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,8 +318,7 @@ unsafe impl VTabCursor for CsvTabCursor<'_> {
|
|||||||
fn column(&self, ctx: &mut Context, col: c_int) -> Result<()> {
|
fn column(&self, ctx: &mut Context, col: c_int) -> Result<()> {
|
||||||
if col < 0 || col as usize >= self.cols.len() {
|
if col < 0 || col as usize >= self.cols.len() {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"column index out of bounds: {}",
|
"column index out of bounds: {col}"
|
||||||
col
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
if self.cols.is_empty() {
|
if self.cols.is_empty() {
|
||||||
|
@ -56,8 +56,7 @@ impl VTabLog {
|
|||||||
"schema" => {
|
"schema" => {
|
||||||
if schema.is_some() {
|
if schema.is_some() {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"more than one '{}' parameter",
|
"more than one '{param}' parameter"
|
||||||
param
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
schema = Some(value.to_owned())
|
schema = Some(value.to_owned())
|
||||||
@ -65,8 +64,7 @@ impl VTabLog {
|
|||||||
"rows" => {
|
"rows" => {
|
||||||
if n_row.is_some() {
|
if n_row.is_some() {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"more than one '{}' parameter",
|
"more than one '{param}' parameter"
|
||||||
param
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
if let Ok(n) = i64::from_str(value) {
|
if let Ok(n) = i64::from_str(value) {
|
||||||
@ -75,8 +73,7 @@ impl VTabLog {
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::ModuleError(format!(
|
return Err(Error::ModuleError(format!(
|
||||||
"unrecognized parameter '{}'",
|
"unrecognized parameter '{param}'"
|
||||||
param
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user