Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from datahub-project:master #1037

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def __post_init__(self) -> None:
# This was added in 3.24.0 from 2018-06-04.
# See https://www.sqlite.org/lang_conflict.html
if OVERRIDE_SQLITE_VERSION_REQUIREMENT:
self.use_sqlite_on_conflict = False
self._use_sqlite_on_conflict = False
else:
raise RuntimeError("SQLite version 3.24.0 or later is required")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sqlite3
from dataclasses import dataclass
from typing import Counter, Dict
from unittest.mock import patch

import pytest

Expand All @@ -15,6 +16,36 @@
)


def test_set_use_sqlite_on_conflict():
with patch("sqlite3.sqlite_version_info", (3, 24, 0)):
cache = FileBackedDict[int](
tablename="cache",
cache_max_size=10,
cache_eviction_batch_size=10,
)
assert cache._use_sqlite_on_conflict is True

with pytest.raises(RuntimeError):
with patch("sqlite3.sqlite_version_info", (3, 23, 1)):
cache = FileBackedDict[int](
tablename="cache",
cache_max_size=10,
cache_eviction_batch_size=10,
)
assert cache._use_sqlite_on_conflict is False

with patch("sqlite3.sqlite_version_info", (3, 23, 1)), patch(
"datahub.utilities.file_backed_collections.OVERRIDE_SQLITE_VERSION_REQUIREMENT",
True,
):
cache = FileBackedDict[int](
tablename="cache",
cache_max_size=10,
cache_eviction_batch_size=10,
)
assert cache._use_sqlite_on_conflict is False


@pytest.mark.parametrize("use_sqlite_on_conflict", [True, False])
def test_file_dict(use_sqlite_on_conflict: bool) -> None:
cache = FileBackedDict[int](
Expand Down
Loading