Skip to content

Commit 3811a33

Browse files
committed
fix(ingest/file-backed-collections): Properly set _use_sqlite_on_conflict
1 parent 58b6a5b commit 3811a33

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-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

+33
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import dataclasses
22
import json
3+
import os
34
import pathlib
45
import random
56
import sqlite3
7+
from unittest.mock import patch
8+
69
from dataclasses import dataclass
710
from typing import Counter, Dict
811

@@ -15,6 +18,36 @@
1518
)
1619

1720

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

0 commit comments

Comments
 (0)