diff options
| -rw-r--r-- | crates/atuin-client/src/record/sqlite_store.rs | 19 | ||||
| -rw-r--r-- | crates/atuin-server-postgres/src/lib.rs | 2 |
2 files changed, 11 insertions, 10 deletions
diff --git a/crates/atuin-client/src/record/sqlite_store.rs b/crates/atuin-client/src/record/sqlite_store.rs index 31de311b..63ef42f8 100644 --- a/crates/atuin-client/src/record/sqlite_store.rs +++ b/crates/atuin-client/src/record/sqlite_store.rs @@ -219,15 +219,16 @@ impl Store for SqliteStore { idx: RecordIdx, limit: u64, ) -> Result<Vec<Record<EncryptedData>>> { - let res = - sqlx::query("select * from store where idx >= ?1 and host = ?2 and tag = ?3 limit ?4") - .bind(idx as i64) - .bind(host.0.as_hyphenated().to_string()) - .bind(tag) - .bind(limit as i64) - .map(Self::query_row) - .fetch_all(&self.pool) - .await?; + let res = sqlx::query( + "select * from store where idx >= ?1 and host = ?2 and tag = ?3 order by idx asc limit ?4", + ) + .bind(idx as i64) + .bind(host.0.as_hyphenated().to_string()) + .bind(tag) + .bind(limit as i64) + .map(Self::query_row) + .fetch_all(&self.pool) + .await?; Ok(res) } diff --git a/crates/atuin-server-postgres/src/lib.rs b/crates/atuin-server-postgres/src/lib.rs index 6c3572bc..47e9486b 100644 --- a/crates/atuin-server-postgres/src/lib.rs +++ b/crates/atuin-server-postgres/src/lib.rs @@ -571,7 +571,7 @@ impl Database for Postgres { "insert into store_idx_cache (user_id, host, tag, idx) values ($1, $2, $3, $4) - on conflict(user_id, host, tag) do update set idx = $4 + on conflict(user_id, host, tag) do update set idx = greatest(idx, $4) ", ) .bind(user.id) |
