Whole file
msiemens/tinydb
The author described this change as “Fix _last_id after opening old DB (closes #34)”. It counts as a record because the check below fails on the code as it stood at 1a27bc898 and passes on 1e865a868, with nothing else changed between the two runs.
Projectmsiemens/tinydb
Fix saved2014-10-14
Sharing licenceMIT · LICENSE
Change size+4 −4
What the code was meant to do, written into the code itself as a save note
Fix _last_id after opening old DB (closes #34)
The change
| 187 | 187 | self._db = db | |
| 188 | 188 | self._query_cache = LRUCache(capacity=cache_size) | |
| 189 | 189 | ||
| 190 | - | try: | |
| 191 | - | all_ids = sorted(self._read().keys()) | |
| 192 | - | self._last_id = int(all_ids.pop()) | |
| 193 | - | except IndexError: | |
| 190 | + | old_ids = self._read().keys() | |
| 191 | + | if old_ids: | |
| 192 | + | self._last_id = max(int(i, 10) for i in old_ids) | |
| 193 | + | else: | |
| 194 | 194 | self._last_id = 0 | |
| 195 | 195 | ||
| 196 | 196 | def process_elements(self, func, cond=None, eids=None): |
The check that tells the two apart
fail→pass·tests/test_tinydb.py::test_lastid_after_open
Check file tests/test_tinydb.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it1a27bc8985cea953c0a32029cba0b2f5b9dd3b9e
Broken version dated2014-10-13
Moduletinydb.database
Units changedTable
Fingerprint459885ec5e48f7a8
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.