Merge new key/values into an index's metadata JSON column.
(self, index_id: str, updates: dict)
| 426 | return deleted |
| 427 | |
| 428 | def update_index_metadata(self, index_id: str, updates: dict): |
| 429 | """Merge new key/values into an index's metadata JSON column.""" |
| 430 | conn = sqlite3.connect(self.db_path) |
| 431 | conn.row_factory = sqlite3.Row |
| 432 | cur = conn.execute('SELECT metadata FROM indexes WHERE id=?', (index_id,)) |
| 433 | row = cur.fetchone() |
| 434 | if row is None: |
| 435 | conn.close() |
| 436 | raise ValueError("Index not found") |
| 437 | existing = json.loads(row['metadata'] or '{}') |
| 438 | existing.update(updates) |
| 439 | conn.execute('UPDATE indexes SET metadata=?, updated_at=? WHERE id=?', (json.dumps(existing), datetime.now().isoformat(), index_id)) |
| 440 | conn.commit() |
| 441 | conn.close() |
| 442 | |
| 443 | def inspect_and_populate_index_metadata(self, index_id: str) -> dict: |
| 444 | """ |
no test coverage detected