mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
fix: clippy warnings
This commit is contained in:
@@ -19,7 +19,7 @@ impl Column for SqliteColumn {
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
&*self.name
|
||||
&self.name
|
||||
}
|
||||
|
||||
fn type_info(&self) -> &SqliteTypeInfo {
|
||||
|
||||
@@ -15,6 +15,7 @@ use crate::SqliteError;
|
||||
#[derive(Clone)]
|
||||
pub struct Collation {
|
||||
name: Arc<str>,
|
||||
#[allow(clippy::type_complexity)]
|
||||
collate: Arc<dyn Fn(&str, &str) -> Ordering + Send + Sync + 'static>,
|
||||
// SAFETY: these must match the concrete type of `collate`
|
||||
call: unsafe extern "C" fn(
|
||||
|
||||
@@ -24,6 +24,7 @@ use std::time::Duration;
|
||||
// https://doc.rust-lang.org/stable/std/sync/atomic/index.html#portability
|
||||
static THREAD_ID: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
enum SqliteLoadExtensionMode {
|
||||
/// Enables only the C-API, leaving the SQL function disabled.
|
||||
Enable,
|
||||
@@ -32,7 +33,7 @@ enum SqliteLoadExtensionMode {
|
||||
}
|
||||
|
||||
impl SqliteLoadExtensionMode {
|
||||
fn as_int(self) -> c_int {
|
||||
fn to_int(self) -> c_int {
|
||||
match self {
|
||||
SqliteLoadExtensionMode::Enable => 1,
|
||||
SqliteLoadExtensionMode::DisableAll => 0,
|
||||
@@ -101,13 +102,13 @@ impl EstablishParams {
|
||||
}
|
||||
|
||||
if let Some(vfs) = options.vfs.as_deref() {
|
||||
query_params.insert("vfs", &vfs);
|
||||
query_params.insert("vfs", vfs);
|
||||
}
|
||||
|
||||
if !query_params.is_empty() {
|
||||
filename = format!(
|
||||
"file:{}?{}",
|
||||
percent_encoding::percent_encode(filename.as_bytes(), &NON_ALPHANUMERIC),
|
||||
percent_encoding::percent_encode(filename.as_bytes(), NON_ALPHANUMERIC),
|
||||
serde_urlencoded::to_string(&query_params).unwrap()
|
||||
);
|
||||
flags |= libsqlite3_sys::SQLITE_OPEN_URI;
|
||||
@@ -174,7 +175,7 @@ impl EstablishParams {
|
||||
let status = sqlite3_db_config(
|
||||
db,
|
||||
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,
|
||||
mode.as_int(),
|
||||
mode.to_int(),
|
||||
null::<i32>(),
|
||||
);
|
||||
|
||||
@@ -294,7 +295,7 @@ impl EstablishParams {
|
||||
transaction_depth: 0,
|
||||
log_settings: self.log_settings.clone(),
|
||||
progress_handler_callback: None,
|
||||
update_hook_callback: None
|
||||
update_hook_callback: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ impl Iterator for ExecuteIter<'_> {
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let statement = if self.goto_next {
|
||||
let mut statement = match self.statement.prepare_next(self.handle) {
|
||||
let statement = match self.statement.prepare_next(self.handle) {
|
||||
Ok(Some(statement)) => statement,
|
||||
Ok(None) => return None,
|
||||
Err(e) => return Some(Err(e.into())),
|
||||
Err(e) => return Some(Err(e)),
|
||||
};
|
||||
|
||||
self.goto_next = false;
|
||||
@@ -83,7 +83,7 @@ impl Iterator for ExecuteIter<'_> {
|
||||
|
||||
statement.handle.clear_bindings();
|
||||
|
||||
match bind(&mut statement.handle, &self.args, self.args_used) {
|
||||
match bind(statement.handle, &self.args, self.args_used) {
|
||||
Ok(args_used) => self.args_used += args_used,
|
||||
Err(e) => return Some(Err(e)),
|
||||
}
|
||||
@@ -98,9 +98,9 @@ impl Iterator for ExecuteIter<'_> {
|
||||
self.logger.increment_rows_returned();
|
||||
|
||||
Some(Ok(Either::Right(SqliteRow::current(
|
||||
&statement.handle,
|
||||
&statement.columns,
|
||||
&statement.column_names,
|
||||
statement.handle,
|
||||
statement.columns,
|
||||
statement.column_names,
|
||||
))))
|
||||
}
|
||||
Ok(false) => {
|
||||
|
||||
@@ -13,13 +13,15 @@ use std::future;
|
||||
impl<'c> Executor<'c> for &'c mut SqliteConnection {
|
||||
type Database = Sqlite;
|
||||
|
||||
fn fetch_many<'e, 'q: 'e, E: 'q>(
|
||||
fn fetch_many<'e, 'q, E>(
|
||||
self,
|
||||
mut query: E,
|
||||
) -> BoxStream<'e, Result<Either<SqliteQueryResult, SqliteRow>, Error>>
|
||||
where
|
||||
'c: 'e,
|
||||
E: Execute<'q, Self::Database>,
|
||||
'q: 'e,
|
||||
E: 'q,
|
||||
{
|
||||
let sql = query.sql();
|
||||
let arguments = match query.take_arguments().map_err(Error::Encode) {
|
||||
@@ -36,13 +38,15 @@ impl<'c> Executor<'c> for &'c mut SqliteConnection {
|
||||
)
|
||||
}
|
||||
|
||||
fn fetch_optional<'e, 'q: 'e, E: 'q>(
|
||||
fn fetch_optional<'e, 'q, E>(
|
||||
self,
|
||||
mut query: E,
|
||||
) -> BoxFuture<'e, Result<Option<SqliteRow>, Error>>
|
||||
where
|
||||
'c: 'e,
|
||||
E: Execute<'q, Self::Database>,
|
||||
'q: 'e,
|
||||
E: 'q,
|
||||
{
|
||||
let sql = query.sql();
|
||||
let arguments = match query.take_arguments().map_err(Error::Encode) {
|
||||
|
||||
@@ -160,7 +160,7 @@ impl ColumnType {
|
||||
}
|
||||
fn map_to_datatype(&self) -> DataType {
|
||||
match self {
|
||||
Self::Single { datatype, .. } => datatype.clone(),
|
||||
Self::Single { datatype, .. } => *datatype,
|
||||
Self::Record(_) => DataType::Null, //If we're trying to coerce to a regular Datatype, we can assume a Record is invalid for the context
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ impl core::fmt::Debug for ColumnType {
|
||||
let mut column_iter = columns.iter();
|
||||
if let Some(item) = column_iter.next() {
|
||||
write!(f, "{:?}", item)?;
|
||||
while let Some(item) = column_iter.next() {
|
||||
for item in column_iter {
|
||||
write!(f, ", {:?}", item)?;
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,7 @@ fn root_block_columns(
|
||||
);
|
||||
}
|
||||
|
||||
return Ok(row_info);
|
||||
Ok(row_info)
|
||||
}
|
||||
|
||||
struct Sequence(i64);
|
||||
@@ -544,7 +544,7 @@ impl BranchList {
|
||||
std::collections::hash_map::Entry::Occupied(entry) => {
|
||||
//already saw a state identical to this one, so no point in processing it
|
||||
state.mem = entry.key().clone(); //replace state.mem since .entry() moved it
|
||||
logger.add_result(state, BranchResult::Dedup(entry.get().clone()));
|
||||
logger.add_result(state, BranchResult::Dedup(*entry.get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -974,7 +974,7 @@ pub(super) fn explain(
|
||||
.and_then(|c| c.columns_ref(&state.mem.t, &state.mem.r))
|
||||
.and_then(|cc| cc.get(&p2))
|
||||
.cloned()
|
||||
.unwrap_or_else(|| ColumnType::default());
|
||||
.unwrap_or_default();
|
||||
|
||||
// insert into p3 the datatype of the col
|
||||
state.mem.r.insert(p3, RegDataType::Single(value));
|
||||
@@ -1123,7 +1123,7 @@ pub(super) fn explain(
|
||||
OP_OPEN_EPHEMERAL | OP_OPEN_AUTOINDEX | OP_SORTER_OPEN => {
|
||||
//Create a new pointer which is referenced by p1
|
||||
let table_info = TableDataType {
|
||||
cols: IntMap::from_dense_record(&vec![ColumnType::null(); p2 as usize]),
|
||||
cols: IntMap::from_elem(ColumnType::null(), p2 as usize),
|
||||
is_empty: Some(true),
|
||||
};
|
||||
|
||||
@@ -1376,7 +1376,7 @@ pub(super) fn explain(
|
||||
state.mem.r.insert(
|
||||
p2,
|
||||
RegDataType::Single(ColumnType::Single {
|
||||
datatype: opcode_to_type(&opcode),
|
||||
datatype: opcode_to_type(opcode),
|
||||
nullable: Some(false),
|
||||
}),
|
||||
);
|
||||
@@ -1490,8 +1490,7 @@ pub(super) fn explain(
|
||||
|
||||
while let Some(result) = result_states.pop() {
|
||||
// find the datatype info from each ResultRow execution
|
||||
let mut idx = 0;
|
||||
for this_col in result {
|
||||
for (idx, this_col) in result.into_iter().enumerate() {
|
||||
let this_type = this_col.map_to_datatype();
|
||||
let this_nullable = this_col.map_to_nullable();
|
||||
if output.len() == idx {
|
||||
@@ -1513,7 +1512,6 @@ pub(super) fn explain(
|
||||
} else {
|
||||
nullable[idx] = this_nullable;
|
||||
}
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::{fmt::Debug, hash::Hash};
|
||||
|
||||
/// Simplistic map implementation built on a Vec of Options (index = key)
|
||||
@@ -65,7 +66,7 @@ impl<V> IntMap<V> {
|
||||
|
||||
let item = self.0.get_mut(idx);
|
||||
match item {
|
||||
Some(content) => std::mem::replace(content, None),
|
||||
Some(content) => content.take(),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
@@ -100,7 +101,10 @@ impl<V: Default> IntMap<V> {
|
||||
}
|
||||
|
||||
impl<V: Clone> IntMap<V> {
|
||||
pub(crate) fn from_dense_record(record: &Vec<V>) -> Self {
|
||||
pub(crate) fn from_elem(elem: V, len: usize) -> Self {
|
||||
Self(vec![Some(elem); len])
|
||||
}
|
||||
pub(crate) fn from_dense_record(record: &[V]) -> Self {
|
||||
Self(record.iter().cloned().map(Some).collect())
|
||||
}
|
||||
}
|
||||
@@ -139,21 +143,16 @@ impl<V: Hash> Hash for IntMap<V> {
|
||||
|
||||
impl<V: PartialEq> PartialEq for IntMap<V> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
if !self
|
||||
.0
|
||||
.iter()
|
||||
.zip(other.0.iter())
|
||||
.all(|(l, r)| PartialEq::eq(l, r))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.0.len() > other.0.len() {
|
||||
self.0[other.0.len()..].iter().all(Option::is_none)
|
||||
} else if self.0.len() < other.0.len() {
|
||||
other.0[self.0.len()..].iter().all(Option::is_none)
|
||||
} else {
|
||||
true
|
||||
match self.0.len().cmp(&other.0.len()) {
|
||||
Ordering::Greater => {
|
||||
self.0[..other.0.len()] == other.0
|
||||
&& self.0[other.0.len()..].iter().all(Option::is_none)
|
||||
}
|
||||
Ordering::Less => {
|
||||
other.0[..self.0.len()] == self.0
|
||||
&& other.0[self.0.len()..].iter().all(Option::is_none)
|
||||
}
|
||||
Ordering::Equal => self.0 == other.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::fmt::Write;
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
use std::os::raw::{c_int, c_void};
|
||||
use std::panic::catch_unwind;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use futures_core::future::BoxFuture;
|
||||
@@ -112,7 +113,7 @@ impl ConnectionState {
|
||||
pub(crate) fn remove_progress_handler(&mut self) {
|
||||
if let Some(mut handler) = self.progress_handler_callback.take() {
|
||||
unsafe {
|
||||
sqlite3_progress_handler(self.handle.as_ptr(), 0, None, std::ptr::null_mut());
|
||||
sqlite3_progress_handler(self.handle.as_ptr(), 0, None, ptr::null_mut());
|
||||
let _ = { Box::from_raw(handler.0.as_mut()) };
|
||||
}
|
||||
}
|
||||
@@ -121,7 +122,7 @@ impl ConnectionState {
|
||||
pub(crate) fn remove_update_hook(&mut self) {
|
||||
if let Some(mut handler) = self.update_hook_callback.take() {
|
||||
unsafe {
|
||||
sqlite3_update_hook(self.handle.as_ptr(), None, std::ptr::null_mut());
|
||||
sqlite3_update_hook(self.handle.as_ptr(), None, ptr::null_mut());
|
||||
let _ = { Box::from_raw(handler.0.as_mut()) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ pub struct QueryPlanLogger<'q, R: Debug + 'static, S: Debug + DebugDiff + 'stati
|
||||
fn dot_escape_string(value: impl AsRef<str>) -> String {
|
||||
value
|
||||
.as_ref()
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "'")
|
||||
.replace("\n", "\\n")
|
||||
.replace('\\', r#"\\"#)
|
||||
.replace('"', "'")
|
||||
.replace('\n', r#"\n"#)
|
||||
.to_string()
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ impl<R: Debug, S: Debug + DebugDiff, P: Debug> core::fmt::Display for QueryPlanL
|
||||
let mut instruction_uses: IntMap<Vec<BranchParent>> = Default::default();
|
||||
for (k, state) in all_states.iter() {
|
||||
let entry = instruction_uses.get_mut_or_default(&(state.program_i as i64));
|
||||
entry.push(k.clone());
|
||||
entry.push(*k);
|
||||
}
|
||||
|
||||
let mut branch_children: std::collections::HashMap<BranchParent, Vec<BranchParent>> =
|
||||
@@ -127,27 +127,27 @@ impl<R: Debug, S: Debug + DebugDiff, P: Debug> core::fmt::Display for QueryPlanL
|
||||
state_list
|
||||
.entry(state_diff)
|
||||
.or_default()
|
||||
.push((curr_ref.clone(), Some(next_ref)));
|
||||
.push((*curr_ref, Some(next_ref)));
|
||||
} else {
|
||||
state_list
|
||||
.entry(Default::default())
|
||||
.or_default()
|
||||
.push((curr_ref.clone(), None));
|
||||
.push((*curr_ref, None));
|
||||
};
|
||||
|
||||
if let Some(children) = branch_children.get(curr_ref) {
|
||||
for next_ref in children {
|
||||
if let Some(next_state) = all_states.get(&next_ref) {
|
||||
if let Some(next_state) = all_states.get(next_ref) {
|
||||
let state_diff = next_state.state.diff(&curr_state.state);
|
||||
|
||||
if !state_diff.is_empty() {
|
||||
branched_with_state.insert(next_ref.clone());
|
||||
branched_with_state.insert(*next_ref);
|
||||
}
|
||||
|
||||
state_list
|
||||
.entry(state_diff)
|
||||
.or_default()
|
||||
.push((curr_ref.clone(), Some(next_ref.clone())));
|
||||
.push((*curr_ref, Some(*next_ref)));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -176,7 +176,7 @@ impl<R: Debug, S: Debug + DebugDiff, P: Debug> core::fmt::Display for QueryPlanL
|
||||
for (curr_ref, next_ref) in ref_list {
|
||||
if let Some(next_ref) = next_ref {
|
||||
let next_program_i = all_states
|
||||
.get(&next_ref)
|
||||
.get(next_ref)
|
||||
.map(|s| s.program_i.to_string())
|
||||
.unwrap_or_default();
|
||||
|
||||
@@ -258,7 +258,7 @@ impl<R: Debug, S: Debug + DebugDiff, P: Debug> core::fmt::Display for QueryPlanL
|
||||
let mut instruction_list: Vec<(BranchParent, &InstructionHistory<S>)> = Vec::new();
|
||||
if let Some(parent) = self.branch_origins.get(&branch_id) {
|
||||
if let Some(parent_state) = all_states.get(parent) {
|
||||
instruction_list.push((parent.clone(), parent_state));
|
||||
instruction_list.push((*parent, parent_state));
|
||||
}
|
||||
}
|
||||
if let Some(instructions) = self.branch_operations.get(&branch_id) {
|
||||
@@ -278,11 +278,11 @@ impl<R: Debug, S: Debug + DebugDiff, P: Debug> core::fmt::Display for QueryPlanL
|
||||
if let Some((cur_ref, _)) = instructions_iter.next() {
|
||||
let mut prev_ref = cur_ref;
|
||||
|
||||
while let Some((cur_ref, _)) = instructions_iter.next() {
|
||||
for (cur_ref, _) in instructions_iter {
|
||||
if branched_with_state.contains(&cur_ref) {
|
||||
write!(
|
||||
writeln!(
|
||||
f,
|
||||
"\"b{}p{}\" -> \"b{}p{}_b{}p{}\" -> \"b{}p{}\"\n",
|
||||
"\"b{}p{}\" -> \"b{}p{}_b{}p{}\" -> \"b{}p{}\"",
|
||||
prev_ref.id,
|
||||
prev_ref.idx,
|
||||
prev_ref.id,
|
||||
@@ -360,7 +360,7 @@ impl<'q, R: Debug, S: Debug + DebugDiff, P: Debug> QueryPlanLogger<'q, R, S, P>
|
||||
return;
|
||||
}
|
||||
let branch: BranchParent = BranchParent::from(state);
|
||||
self.branch_origins.insert(branch.id, parent.clone());
|
||||
self.branch_origins.insert(branch.id, *parent);
|
||||
}
|
||||
|
||||
pub fn add_operation<I: Copy>(&mut self, program_i: usize, state: I)
|
||||
@@ -402,14 +402,14 @@ impl<'q, R: Debug, S: Debug + DebugDiff, P: Debug> QueryPlanLogger<'q, R, S, P>
|
||||
return;
|
||||
}
|
||||
|
||||
let mut summary = parse_query_summary(&self.sql);
|
||||
let mut summary = parse_query_summary(self.sql);
|
||||
|
||||
let sql = if summary != self.sql {
|
||||
summary.push_str(" …");
|
||||
format!(
|
||||
"\n\n{}\n",
|
||||
sqlformat::format(
|
||||
&self.sql,
|
||||
self.sql,
|
||||
&sqlformat::QueryParams::None,
|
||||
sqlformat::FormatOptions::default()
|
||||
)
|
||||
|
||||
@@ -28,8 +28,7 @@ impl MigrateDatabase for Sqlite {
|
||||
}
|
||||
|
||||
// Opening a connection to sqlite creates the database
|
||||
let _ = opts
|
||||
.connect()
|
||||
opts.connect()
|
||||
.await?
|
||||
// Ensure WAL mode tempfiles are cleaned up
|
||||
.close()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use crate::error::Error;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SqliteAutoVacuum {
|
||||
#[default]
|
||||
None,
|
||||
Full,
|
||||
Incremental,
|
||||
@@ -18,12 +19,6 @@ impl SqliteAutoVacuum {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SqliteAutoVacuum {
|
||||
fn default() -> Self {
|
||||
SqliteAutoVacuum::None
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for SqliteAutoVacuum {
|
||||
type Err = Error;
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@ use std::str::FromStr;
|
||||
/// Refer to [SQLite documentation] for the meaning of the database journaling mode.
|
||||
///
|
||||
/// [SQLite documentation]: https://www.sqlite.org/pragma.html#pragma_journal_mode
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SqliteJournalMode {
|
||||
Delete,
|
||||
Truncate,
|
||||
Persist,
|
||||
Memory,
|
||||
#[default]
|
||||
Wal,
|
||||
Off,
|
||||
}
|
||||
@@ -27,12 +28,6 @@ impl SqliteJournalMode {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SqliteJournalMode {
|
||||
fn default() -> Self {
|
||||
SqliteJournalMode::Wal
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for SqliteJournalMode {
|
||||
type Err = Error;
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ use std::str::FromStr;
|
||||
/// Refer to [SQLite documentation] for the meaning of the connection locking mode.
|
||||
///
|
||||
/// [SQLite documentation]: https://www.sqlite.org/pragma.html#pragma_locking_mode
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SqliteLockingMode {
|
||||
#[default]
|
||||
Normal,
|
||||
Exclusive,
|
||||
}
|
||||
@@ -19,12 +20,6 @@ impl SqliteLockingMode {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SqliteLockingMode {
|
||||
fn default() -> Self {
|
||||
SqliteLockingMode::Normal
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for SqliteLockingMode {
|
||||
type Err = Error;
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ impl SqliteConnectOptions {
|
||||
.append_pair("immutable", &self.immutable.to_string());
|
||||
|
||||
if let Some(vfs) = &self.vfs {
|
||||
url.query_pairs_mut().append_pair("vfs", &vfs);
|
||||
url.query_pairs_mut().append_pair("vfs", vfs);
|
||||
}
|
||||
|
||||
url
|
||||
|
||||
@@ -4,10 +4,11 @@ use std::str::FromStr;
|
||||
/// Refer to [SQLite documentation] for the meaning of various synchronous settings.
|
||||
///
|
||||
/// [SQLite documentation]: https://www.sqlite.org/pragma.html#pragma_synchronous
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SqliteSynchronous {
|
||||
Off,
|
||||
Normal,
|
||||
#[default]
|
||||
Full,
|
||||
Extra,
|
||||
}
|
||||
@@ -23,12 +24,6 @@ impl SqliteSynchronous {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SqliteSynchronous {
|
||||
fn default() -> Self {
|
||||
SqliteSynchronous::Full
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for SqliteSynchronous {
|
||||
type Err = Error;
|
||||
|
||||
|
||||
@@ -68,16 +68,12 @@ unsafe extern "C" fn sqlite3_regexp_func(
|
||||
}
|
||||
|
||||
// arg0: Regex
|
||||
let regex = if let Some(regex) = get_regex_from_arg(ctx, *args.offset(0), 0) {
|
||||
regex
|
||||
} else {
|
||||
let Some(regex) = get_regex_from_arg(ctx, *args.offset(0), 0) else {
|
||||
return;
|
||||
};
|
||||
|
||||
// arg1: value
|
||||
let value = if let Some(text) = get_text_from_arg(ctx, *args.offset(1)) {
|
||||
text
|
||||
} else {
|
||||
let Some(value) = get_text_from_arg(ctx, *args.offset(1)) else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ impl ColumnIndex<SqliteRow> for &'_ str {
|
||||
row.column_names
|
||||
.get(*self)
|
||||
.ok_or_else(|| Error::ColumnNotFound((*self).into()))
|
||||
.map(|v| *v)
|
||||
.copied()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ impl ColumnIndex<SqliteStatement<'_>> for &'_ str {
|
||||
.column_names
|
||||
.get(*self)
|
||||
.ok_or_else(|| Error::ColumnNotFound((*self).into()))
|
||||
.map(|v| *v)
|
||||
.copied()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,12 +147,15 @@ fn prepare(
|
||||
) -> Result<Option<StatementHandle>, Error> {
|
||||
let mut flags = 0;
|
||||
|
||||
// For some reason, when building with the `sqlcipher` feature enabled
|
||||
// `SQLITE_PREPARE_PERSISTENT` ends up being `i32` instead of `u32`. Crazy, right?
|
||||
#[allow(trivial_casts, clippy::unnecessary_cast)]
|
||||
if persistent {
|
||||
// SQLITE_PREPARE_PERSISTENT
|
||||
// The SQLITE_PREPARE_PERSISTENT flag is a hint to the query
|
||||
// planner that the prepared statement will be retained for a long time
|
||||
// and probably reused many times.
|
||||
flags |= SQLITE_PREPARE_PERSISTENT;
|
||||
flags |= SQLITE_PREPARE_PERSISTENT as u32;
|
||||
}
|
||||
|
||||
while !query.is_empty() {
|
||||
@@ -168,7 +171,7 @@ fn prepare(
|
||||
conn,
|
||||
query_ptr,
|
||||
query_len,
|
||||
flags as u32,
|
||||
flags,
|
||||
&mut statement_handle,
|
||||
&mut tail,
|
||||
)
|
||||
|
||||
@@ -11,10 +11,7 @@ const BASE_PATH: &str = "target/sqlx/test-dbs";
|
||||
|
||||
impl TestSupport for Sqlite {
|
||||
fn test_context(args: &TestArgs) -> BoxFuture<'_, Result<TestContext<Self>, Error>> {
|
||||
Box::pin(async move {
|
||||
let res = test_context(args).await;
|
||||
res
|
||||
})
|
||||
Box::pin(async move { test_context(args).await })
|
||||
}
|
||||
|
||||
fn cleanup_test(db_name: &str) -> BoxFuture<'_, Result<(), Error>> {
|
||||
|
||||
Reference in New Issue
Block a user