Skip to content

Commit 92f013e

Browse files
authored
fix(ingest/file-backed-collections): Properly set _use_sqlite_on_conflict (datahub-project#12297)
1 parent 58b6a5b commit 92f013e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

metadata-ingestion/src/datahub/utilities/file_backed_collections.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def __post_init__(self) -> None:
243243
# This was added in 3.24.0 from 2018-06-04.
244244
# See https://www.sqlite.org/lang_conflict.html
245245
if OVERRIDE_SQLITE_VERSION_REQUIREMENT:
246-
self.use_sqlite_on_conflict = False
246+
self._use_sqlite_on_conflict = False
247247
else:
248248
raise RuntimeError("SQLite version 3.24.0 or later is required")
249249

metadata-ingestion/tests/unit/utilities/test_file_backed_collections.py

+31
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sqlite3
66
from dataclasses import dataclass
77
from typing import Counter, Dict
8+
from unittest.mock import patch
89

910
import pytest
1011

@@ -15,6 +16,36 @@
1516
)
1617

1718

19+
def test_set_use_sqlite_on_conflict():
20+
with patch("sqlite3.sqlite_version_info", (3, 24, 0)):
21+
cache = FileBackedDict[int](
22+
tablename="cache",
23+
cache_max_size=10,
24+
cache_eviction_batch_size=10,
25+
)
26+
assert cache._use_sqlite_on_conflict is True
27+
28+
with pytest.raises(RuntimeError):
29+
with patch("sqlite3.sqlite_version_info", (3, 23, 1)):
30+
cache = FileBackedDict[int](
31+
tablename="cache",
32+
cache_max_size=10,
33+
cache_eviction_batch_size=10,
34+
)
35+
assert cache._use_sqlite_on_conflict is False
36+
37+
with patch("sqlite3.sqlite_version_info", (3, 23, 1)), patch(
38+
"datahub.utilities.file_backed_collections.OVERRIDE_SQLITE_VERSION_REQUIREMENT",
39+
True,
40+
):
41+
cache = FileBackedDict[int](
42+
tablename="cache",
43+
cache_max_size=10,
44+
cache_eviction_batch_size=10,
45+
)
46+
assert cache._use_sqlite_on_conflict is False
47+
48+
1849
@pytest.mark.parametrize("use_sqlite_on_conflict", [True, False])
1950
def test_file_dict(use_sqlite_on_conflict: bool) -> None:
2051
cache = FileBackedDict[int](

0 commit comments

Comments
 (0)