sql: use sqlite3_last_insert_rowid instead of SELECT

This commit is contained in:
link2xt
2021-04-17 05:54:41 +03:00
parent 59dea29e88
commit e35a8d4415
6 changed files with 40 additions and 124 deletions

View File

@@ -571,9 +571,9 @@ pub async fn save(
.exists(sqlx::query(stmt_test).bind(timestamp).bind(contact_id))
.await?;
if independent || !exists {
context
let row_id = context
.sql
.execute(
.insert(
sqlx::query(stmt_insert)
.bind(timestamp)
.bind(contact_id)
@@ -587,16 +587,7 @@ pub async fn save(
if timestamp > newest_timestamp {
newest_timestamp = timestamp;
newest_location_id = context
.sql
.get_rowid2(
"locations",
"timestamp",
timestamp,
"from_id",
contact_id as i64,
)
.await?;
newest_location_id = row_id;
}
}
}