mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 07:09:20 +08:00
[breaking change] Update edition from 2018 to 2021
And fix clippy warnings
This commit is contained in:
parent
51a69b1b74
commit
3aa9addaa3
@ -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.28.0"
|
version = "0.28.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 = "http://docs.rs/rusqlite/"
|
documentation = "http://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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ mod test {
|
|||||||
));
|
));
|
||||||
blob.raw_read_at_exact(&mut s2, 5).unwrap_err();
|
blob.raw_read_at_exact(&mut s2, 5).unwrap_err();
|
||||||
|
|
||||||
let end_pos = blob.seek(std::io::SeekFrom::Current(0)).unwrap();
|
let end_pos = blob.stream_position().unwrap();
|
||||||
assert_eq!(end_pos, 1);
|
assert_eq!(end_pos, 1);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ impl Drop for InnerConnection {
|
|||||||
if panicking() {
|
if panicking() {
|
||||||
eprintln!("Error while closing SQLite connection: {e:?}");
|
eprintln!("Error while closing SQLite connection: {e:?}");
|
||||||
} else {
|
} else {
|
||||||
panic!("Error while closing SQLite connection: {:?}", e);
|
panic!("Error while closing SQLite connection: {e:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
src/lib.rs
31
src/lib.rs
@ -1291,9 +1291,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");
|
||||||
@ -1421,8 +1419,7 @@ mod test {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
err,
|
err,
|
||||||
Error::ExecuteReturnedResults,
|
Error::ExecuteReturnedResults,
|
||||||
"Unexpected error: {}",
|
"Unexpected error: {err}"
|
||||||
err
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1438,7 +1435,7 @@ mod test {
|
|||||||
.unwrap_err();
|
.unwrap_err();
|
||||||
match err {
|
match err {
|
||||||
Error::MultipleStatement => (),
|
Error::MultipleStatement => (),
|
||||||
_ => panic!("Unexpected error: {}", err),
|
_ => panic!("Unexpected error: {err}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1549,7 +1546,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(()));
|
||||||
@ -1601,7 +1598,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(())
|
||||||
@ -1688,7 +1685,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(())
|
||||||
}
|
}
|
||||||
@ -1870,7 +1867,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>> =
|
||||||
@ -1878,7 +1875,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(())
|
||||||
}
|
}
|
||||||
@ -1923,7 +1920,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
|
||||||
@ -1932,7 +1929,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
|
||||||
@ -1941,7 +1938,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(())
|
||||||
}
|
}
|
||||||
@ -1978,7 +1975,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> =
|
||||||
@ -1986,7 +1983,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> =
|
||||||
@ -1994,7 +1991,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(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,12 +1272,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(())
|
||||||
}
|
}
|
||||||
@ -1532,7 +1532,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(())
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,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),
|
||||||
@ -248,7 +247,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 {
|
||||||
|
@ -352,7 +352,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(())
|
||||||
|
@ -100,7 +100,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