Skip to content

Commit bdfd277

Browse files
authored
Merge pull request #233 from Wolfvin/fix/node-types-language-list-and-cache-tiebreak
fix(tests,registry): outdated language test-list + cache overwrite tiebreak bug
2 parents 9655a09 + 3863b4a commit bdfd277

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

scripts/persistent_registry.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,17 @@ def get_cached_result(
572572
return None
573573

574574
conn = self._connect()
575+
# Tiebreak on the autoincrement id (monotonic) in addition to
576+
# timestamp: set_cached_result() does a plain INSERT (not an
577+
# upsert), so two writes for the same (command, file_set_hash) in
578+
# quick succession can land on the same time.time() value (limited
579+
# clock resolution) — ORDER BY timestamp alone then returns
580+
# whichever row SQLite picks arbitrarily on the tie, which can be
581+
# the stale one.
575582
row = conn.execute(
576583
"""SELECT result_json FROM analysis_cache
577584
WHERE command = ? AND file_set_hash = ?
578-
ORDER BY timestamp DESC LIMIT 1
585+
ORDER BY timestamp DESC, id DESC LIMIT 1
579586
""",
580587
(command, file_set_hash),
581588
).fetchone()

tests/test_node_types.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,13 @@ def test_unknown_language_raises(self):
162162

163163

164164
class TestGetSupportedLanguages:
165-
"""``get_supported_languages()`` lists all 7 tree-sitter languages."""
165+
"""``get_supported_languages()`` lists all 13 tree-sitter languages."""
166166

167+
# Issue #198 added go/java/php/ruby/c/cpp (6 languages) alongside the
168+
# original 7 (python/rust/javascript/typescript/tsx/css/html) -> 13 total.
167169
EXPECTED_LANGUAGES = {
168-
"python", "rust", "javascript", "typescript", "tsx", "css", "html"
170+
"python", "rust", "javascript", "typescript", "tsx", "css", "html",
171+
"go", "java", "php", "ruby", "c", "cpp",
169172
}
170173

171174
def test_all_expected_languages_present(self):

0 commit comments

Comments
 (0)