sql: cleanup usage of ToSql

Moved custom ToSql trait including Send + Sync from lib.rs to sql.rs.
Replaced most params! and paramsv! macro usage with tuples.

Replaced paramsv! and params_iterv! with params_slice!,
because there is no need to construct a vector.
This commit is contained in:
link2xt
2023-04-12 22:12:46 +00:00
parent f1eeb1df8c
commit 619b849ce7
30 changed files with 349 additions and 420 deletions

View File

@@ -75,7 +75,7 @@ async fn lookup_host_with_cache(
VALUES (?, ?, ?)
ON CONFLICT (hostname, address)
DO UPDATE SET timestamp=excluded.timestamp",
paramsv![hostname, ip_string, now],
(hostname, ip_string, now),
)
.await?;
}
@@ -89,7 +89,7 @@ async fn lookup_host_with_cache(
WHERE hostname = ?
AND ? < timestamp + 30 * 24 * 3600
ORDER BY timestamp DESC",
paramsv![hostname, now],
(hostname, now),
|row| {
let address: String = row.get(0)?;
Ok(address)
@@ -157,7 +157,7 @@ pub(crate) async fn connect_tcp(
"UPDATE dns_cache
SET timestamp = ?
WHERE address = ?",
paramsv![time(), resolved_addr.ip().to_string()],
(time(), resolved_addr.ip().to_string()),
)
.await?;
break;