mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 19:06:35 +03:00
Rename query_row_col to query_get_value
Since function `query_row_col` no longer accept column number argument, it is misleading to mention column in its name.
This commit is contained in:
16
src/chat.rs
16
src/chat.rs
@@ -139,7 +139,7 @@ impl Chat {
|
||||
if self.typ == Chattype::Single {
|
||||
return context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT c.addr FROM chats_contacts cc \
|
||||
LEFT JOIN contacts c ON c.id=cc.contact_id \
|
||||
@@ -277,7 +277,7 @@ impl Chat {
|
||||
};
|
||||
|
||||
if self.typ == Chattype::Single {
|
||||
if let Some(id) = context.sql.query_row_col(
|
||||
if let Some(id) = context.sql.query_get_value(
|
||||
context,
|
||||
"SELECT contact_id FROM chats_contacts WHERE chat_id=?;",
|
||||
params![self.id as i32],
|
||||
@@ -721,7 +721,7 @@ fn prepare_msg_common(context: &Context, chat_id: u32, msg: &mut Message) -> Res
|
||||
}
|
||||
|
||||
fn last_msg_in_chat_encrypted(context: &Context, sql: &Sql, chat_id: u32) -> bool {
|
||||
let packed: Option<String> = sql.query_row_col(
|
||||
let packed: Option<String> = sql.query_get_value(
|
||||
context,
|
||||
"SELECT param \
|
||||
FROM msgs WHERE timestamp=(SELECT MAX(timestamp) FROM msgs WHERE chat_id=?) \
|
||||
@@ -908,7 +908,7 @@ unsafe fn set_draft_raw(context: &Context, chat_id: u32, mut msg: Option<&mut Me
|
||||
fn get_draft_msg_id(context: &Context, chat_id: u32) -> u32 {
|
||||
context
|
||||
.sql
|
||||
.query_row_col::<_, i32>(
|
||||
.query_get_value::<_, i32>(
|
||||
context,
|
||||
"SELECT id FROM msgs WHERE chat_id=? AND state=?;",
|
||||
params![chat_id as i32, MessageState::OutDraft],
|
||||
@@ -1002,7 +1002,7 @@ pub fn get_chat_msgs(context: &Context, chat_id: u32, flags: u32, marker1before:
|
||||
pub fn get_msg_cnt(context: &Context, chat_id: u32) -> usize {
|
||||
context
|
||||
.sql
|
||||
.query_row_col::<_, i32>(
|
||||
.query_get_value::<_, i32>(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM msgs WHERE chat_id=?;",
|
||||
params![chat_id as i32],
|
||||
@@ -1013,7 +1013,7 @@ pub fn get_msg_cnt(context: &Context, chat_id: u32) -> usize {
|
||||
pub fn get_fresh_msg_cnt(context: &Context, chat_id: u32) -> usize {
|
||||
context
|
||||
.sql
|
||||
.query_row_col::<_, i32>(
|
||||
.query_get_value::<_, i32>(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM msgs \
|
||||
WHERE state=10 \
|
||||
@@ -1784,7 +1784,7 @@ pub unsafe fn forward_msgs(
|
||||
pub fn get_chat_contact_cnt(context: &Context, chat_id: u32) -> libc::c_int {
|
||||
context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM chats_contacts WHERE chat_id=?;",
|
||||
params![chat_id as i32],
|
||||
@@ -1797,7 +1797,7 @@ pub fn get_chat_cnt(context: &Context) -> usize {
|
||||
/* no database, no chats - this is no error (needed eg. for information) */
|
||||
context
|
||||
.sql
|
||||
.query_row_col::<_, isize>(
|
||||
.query_get_value::<_, isize>(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM chats WHERE id>9 AND blocked=0;",
|
||||
params![],
|
||||
|
||||
@@ -301,7 +301,7 @@ impl Chatlist {
|
||||
pub fn dc_get_archived_cnt(context: &Context) -> u32 {
|
||||
context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM chats WHERE blocked=0 AND archived=1;",
|
||||
params![],
|
||||
@@ -314,7 +314,7 @@ fn get_last_deaddrop_fresh_msg(context: &Context) -> u32 {
|
||||
// only few fresh messages.
|
||||
context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT m.id FROM msgs m LEFT JOIN chats c ON c.id=m.chat_id \
|
||||
WHERE m.state=10 \
|
||||
|
||||
@@ -264,7 +264,7 @@ impl Contact {
|
||||
return 1;
|
||||
}
|
||||
|
||||
context.sql.query_row_col(
|
||||
context.sql.query_get_value(
|
||||
context,
|
||||
"SELECT id FROM contacts WHERE addr=?1 COLLATE NOCASE AND id>?2 AND origin>=?3 AND blocked=0;",
|
||||
params![
|
||||
@@ -537,7 +537,7 @@ impl Contact {
|
||||
pub fn get_blocked_cnt(context: &Context) -> usize {
|
||||
context
|
||||
.sql
|
||||
.query_row_col::<_, isize>(
|
||||
.query_get_value::<_, isize>(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM contacts WHERE id>? AND blocked!=0",
|
||||
params![DC_CONTACT_ID_LAST_SPECIAL as i32],
|
||||
@@ -643,7 +643,7 @@ impl Contact {
|
||||
|
||||
let count_contacts: i32 = context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM chats_contacts WHERE contact_id=?;",
|
||||
params![contact_id as i32],
|
||||
@@ -653,7 +653,7 @@ impl Contact {
|
||||
let count_msgs: i32 = if count_contacts > 0 {
|
||||
context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM msgs WHERE from_id=? OR to_id=?;",
|
||||
params![contact_id as i32, contact_id as i32],
|
||||
@@ -840,7 +840,7 @@ impl Contact {
|
||||
|
||||
context
|
||||
.sql
|
||||
.query_row_col::<_, isize>(
|
||||
.query_get_value::<_, isize>(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM contacts WHERE id>?;",
|
||||
params![DC_CONTACT_ID_LAST_SPECIAL as i32],
|
||||
|
||||
@@ -349,13 +349,13 @@ pub unsafe fn dc_get_info(context: &Context) -> *mut libc::c_char {
|
||||
.get_config_int(context, "mdns_enabled")
|
||||
.unwrap_or_else(|| 1);
|
||||
|
||||
let prv_key_cnt: Option<isize> = context.sql.query_row_col(
|
||||
let prv_key_cnt: Option<isize> = context.sql.query_get_value(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM keypairs;",
|
||||
rusqlite::NO_PARAMS,
|
||||
);
|
||||
|
||||
let pub_key_cnt: Option<isize> = context.sql.query_row_col(
|
||||
let pub_key_cnt: Option<isize> = context.sql.query_get_value(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM acpeerstates;",
|
||||
rusqlite::NO_PARAMS,
|
||||
|
||||
@@ -606,7 +606,7 @@ unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char
|
||||
|
||||
let total_files_cnt = context
|
||||
.sql
|
||||
.query_row_col::<_, isize>(context, "SELECT COUNT(*) FROM backup_blobs;", params![])
|
||||
.query_get_value::<_, isize>(context, "SELECT COUNT(*) FROM backup_blobs;", params![])
|
||||
.unwrap_or_default() as usize;
|
||||
info!(
|
||||
context,
|
||||
|
||||
@@ -991,7 +991,7 @@ unsafe fn calc_timestamps(
|
||||
}
|
||||
*sort_timestamp = message_timestamp;
|
||||
if 0 != is_fresh_msg {
|
||||
let last_msg_time: Option<i64> = context.sql.query_row_col(
|
||||
let last_msg_time: Option<i64> = context.sql.query_get_value(
|
||||
context,
|
||||
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=? and from_id!=? AND timestamp>=?",
|
||||
params![chat_id as i32, from_id as i32, *sort_timestamp],
|
||||
|
||||
@@ -182,7 +182,7 @@ impl Job {
|
||||
);
|
||||
let chat_id: i32 = context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT chat_id FROM msgs WHERE id=?",
|
||||
params![self.foreign_id as i32],
|
||||
@@ -598,7 +598,7 @@ pub fn perform_smtp_idle(context: &Context) {
|
||||
fn get_next_wakeup_time(context: &Context, thread: Thread) -> Duration {
|
||||
let t: i64 = context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT MIN(desired_timestamp) FROM jobs WHERE thread=?;",
|
||||
params![thread],
|
||||
|
||||
@@ -143,7 +143,7 @@ impl Key {
|
||||
) -> Option<Self> {
|
||||
let addr = self_addr.as_ref();
|
||||
|
||||
sql.query_row_col(
|
||||
sql.query_get_value(
|
||||
context,
|
||||
"SELECT public_key FROM keypairs WHERE addr=? AND is_default=1;",
|
||||
&[addr],
|
||||
@@ -156,7 +156,7 @@ impl Key {
|
||||
self_addr: impl AsRef<str>,
|
||||
sql: &Sql,
|
||||
) -> Option<Self> {
|
||||
sql.query_row_col(
|
||||
sql.query_get_value(
|
||||
context,
|
||||
"SELECT private_key FROM keypairs WHERE addr=? AND is_default=1;",
|
||||
&[self_addr.as_ref()],
|
||||
|
||||
@@ -33,7 +33,7 @@ impl<'a> Keyring<'a> {
|
||||
self_addr: impl AsRef<str>,
|
||||
sql: &Sql,
|
||||
) -> bool {
|
||||
sql.query_row_col(
|
||||
sql.query_get_value(
|
||||
context,
|
||||
"SELECT private_key FROM keypairs ORDER BY addr=? DESC, is_default DESC;",
|
||||
&[self_addr.as_ref()],
|
||||
|
||||
@@ -173,7 +173,7 @@ pub unsafe fn dc_get_msg_info(context: &Context, msg_id: u32) -> *mut libc::c_ch
|
||||
|
||||
let msg = msg.unwrap();
|
||||
|
||||
let rawtxt: Option<String> = context.sql.query_row_col(
|
||||
let rawtxt: Option<String> = context.sql.query_get_value(
|
||||
context,
|
||||
"SELECT txt_raw FROM msgs WHERE id=?;",
|
||||
params![msg_id as i32],
|
||||
@@ -490,7 +490,7 @@ pub fn dc_msg_load_from_db(context: &Context, id: u32) -> Result<Message, Error>
|
||||
}
|
||||
|
||||
pub unsafe fn dc_get_mime_headers(context: &Context, msg_id: u32) -> *mut libc::c_char {
|
||||
let headers: Option<String> = context.sql.query_row_col(
|
||||
let headers: Option<String> = context.sql.query_get_value(
|
||||
context,
|
||||
"SELECT mime_headers FROM msgs WHERE id=?;",
|
||||
params![msg_id as i32],
|
||||
@@ -1006,7 +1006,7 @@ pub fn dc_msg_exists(context: &Context, msg_id: u32) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
let chat_id: Option<u32> = context.sql.query_row_col(
|
||||
let chat_id: Option<u32> = context.sql.query_get_value(
|
||||
context,
|
||||
"SELECT chat_id FROM msgs WHERE id=?;",
|
||||
params![msg_id],
|
||||
@@ -1128,7 +1128,7 @@ pub unsafe fn dc_mdn_from_ext(
|
||||
/* send event about new state */
|
||||
let ist_cnt: i32 = context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT COUNT(*) FROM msgs_mdns WHERE msg_id=?;",
|
||||
params![*ret_msg_id as i32],
|
||||
|
||||
@@ -754,7 +754,7 @@ pub fn handle_degrade_event(context: &Context, peerstate: &Peerstate) {
|
||||
if Some(DegradeEvent::FingerprintChanged) == peerstate.degrade_event {
|
||||
let contact_id: i32 = context
|
||||
.sql
|
||||
.query_row_col(
|
||||
.query_get_value(
|
||||
context,
|
||||
"SELECT id FROM contacts WHERE addr=?;",
|
||||
params![&peerstate.addr],
|
||||
|
||||
@@ -155,7 +155,7 @@ impl Sql {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn query_row_col<P, T>(&self, context: &Context, query: &str, params: P) -> Option<T>
|
||||
pub fn query_get_value<P, T>(&self, context: &Context, query: &str, params: P) -> Option<T>
|
||||
where
|
||||
P: IntoIterator,
|
||||
P::Item: rusqlite::ToSql,
|
||||
@@ -232,7 +232,7 @@ impl Sql {
|
||||
if !self.is_open() || key.as_ref().is_empty() {
|
||||
return None;
|
||||
}
|
||||
self.query_row_col(
|
||||
self.query_get_value(
|
||||
context,
|
||||
"SELECT value FROM config WHERE keyname=?;",
|
||||
params![key.as_ref()],
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn save(context: &Context, namespace: Namespace, foreign_id: u32) -> String
|
||||
}
|
||||
|
||||
pub fn lookup(context: &Context, namespace: Namespace, foreign_id: u32) -> Option<String> {
|
||||
context.sql.query_row_col::<_, String>(
|
||||
context.sql.query_get_value::<_, String>(
|
||||
context,
|
||||
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=?;",
|
||||
params![namespace, foreign_id as i32],
|
||||
|
||||
Reference in New Issue
Block a user