Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/core/storage/local_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class LocalDb {
'''
SELECT id FROM sql_query_history
WHERE connection_id = ? AND database_name IS NOT DISTINCT FROM ?
ORDER BY recorded_at ASC, id ASC
ORDER BY id ASC
LIMIT ?
''',
[connectionId, databaseName, excess],
Expand Down Expand Up @@ -340,7 +340,7 @@ class LocalDb {
SELECT id, connection_id, database_name, sql_text, recorded_at
FROM sql_query_history
WHERE connection_id = ? AND database_name IS NOT DISTINCT FROM ?
ORDER BY recorded_at DESC, id DESC
ORDER BY id DESC
LIMIT ?
''',
[connectionId, dbKey, limit],
Expand All @@ -350,6 +350,7 @@ class LocalDb {

/// Removes all history rows for [connectionId] (every database bucket).
Future<void> clearSqlQueryHistoryForConnection(int connectionId) async {
_historyInsertCounts.removeWhere((k, _) => k.startsWith('$connectionId::'));
final db = await _open();
await db.delete(
'sql_query_history',
Expand All @@ -363,8 +364,9 @@ class LocalDb {
required int connectionId,
String? databaseName,
}) async {
final db = await _open();
final dbKey = _normalizeHistoryDatabaseName(databaseName);
_historyInsertCounts.remove('$connectionId::${dbKey ?? ''}');
final db = await _open();
await db.rawDelete(
'''
DELETE FROM sql_query_history
Expand Down Expand Up @@ -524,6 +526,7 @@ class LocalDb {
/// Deletes a connection. SQLite deletion always proceeds even if the secure
/// store delete fails (e.g. missing key or unavailable libsecret daemon).
Future<void> removeConnection(int id) async {
_historyInsertCounts.removeWhere((k, _) => k.startsWith('$id::'));
try {
await ConnectionSecretsStore.deleteForConnection(id);
} catch (_) {
Expand Down
Loading